Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4101006
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T20:38:26+00:00 2026-05-20T20:38:26+00:00

I’m in a embedded led measuring system project now. It uses ARM & linux,

  • 0

I’m in a embedded led measuring system project now. It uses ARM & linux, and has 64M memory and 1G storage. When measuring, it’s supposed to write data to a .csv file. I did it this way:

  1. Create/open a file before measurement begins
  2. In the measuring loop, when data is ready, put it into the file, then go to next measuring
  3. When user stop the measurement, the file will be closed

But, when I add this feature, the program keep running several hours, then the machine won’t respond to anything ( measuring stopped, UI still display but doesn’t respond to any action, etc.). And the csv file is about 15MB.
While without this feature, the machine can work well all day.
I’ve thought about this, maybe It’s because the memory is used up. With such a small memory, is it possible to keep writing a file? Or should I close it every time I finished writing data? (In that case, I will have to open/close the file very frequently, it will cause our system to be slow, what is not glad to see)
Apologize for my poor English, maybe someone can understand it and give me some help.
God is lighting your path, thank you all!

ps: I do believe the file operations itself is correct.

the code like this:

std::ofstream out_put;
out_put.open(filePath, std::ofstream::out | std::ofstream::trunc);

while(!userStoped()){

    doSomeMesuring();

    for(int itemIndex = 0; itemIndex < itemCount; ++itemIndex){
    out_put << ',' << itemName.toStdString() << ',' 
            << data->mdata.item[itemIndex].mvalue << ',' 
            << data->mdata.item[itemIndex].judge << std::endl;
    }
}

out_put.close();
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T20:38:27+00:00Added an answer on May 20, 2026 at 8:38 pm

    You write to ‘out_put’, the ofstream, but never check if the stream is still valid.
    You could change it to

    while (out_put.good() && (!userStoped())
    

    To prove to yourself that it is the writing to a stream which is causing the problem, comment out all of the measuring code, just write lots of ‘x’ (or your choice of character!) to the stream to see if you have the same result.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace
In my XML file chapters tag has more chapter tag.i need to display chapters

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.