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

  • SEARCH
  • Home
  • 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 9229405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:33:49+00:00 2026-06-18T05:33:49+00:00

The code needs to find and process files that have not yet been processed

  • 0

The code needs to find and process files that have not yet been processed on embedded-linux.
getDir is used to return the sorted contents of a directory.
The code below works perfectly after processing several few dozen or maybe more than 100 files but then dies with oom-killer.
Is this a bad way to use c++ vectors (loop vector inside loop vector)?
Might this method be causing the oom-killer?
Is there another approach that might work without blowing up?
Shouldn’t each vector be destroyed as it goes out of scope?
Does new/delete need to be used instead?
Also: valgrind for finding memory leaks is not integrated in the sdk for this processor (TI DM368) but the code is very short and there are no new statements. Note: the actual code checks an sql database for files that have already been processed but this code still caused oom-killer with the sql code commented out so it has been left out for simplicity. The file path format is /YYYYmmdd/HH/MMSS.SS.ext.

void getDir (string dir, vector<string> &files) {
    ...
    while ((dirp = readdir(dp)) != NULL) {
        files.push_back(string(dirp->d_name));
    closedir(dp);
    sort(files.begin(), files.end());

while (true) {
    vector<string> days;
    getDir(database_location, days);
    for (uint d=0; d<days.size(); d++) {
        vector<string> hours;
        getDir(database_location+days[d], hours);
        for (uint h=0; h<hours.size(); h++) {
            vector<string> files;
            string dir = database_location+days[d]+"/"+hours[h];
            getDir(dir, files);
            for (uint f=0; f<files.size(); f++) process(dir, files[f]);
  • 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-06-18T05:33:50+00:00Added an answer on June 18, 2026 at 5:33 am
    1. Linux OOM killer is notoriously dumb. By default, don’t start blaming your own code.
    2. You only have three vectors, of reasonable sizes. (If the vector size is unreasonable, it would be because the number of files in a single dir is also unreasonable).
    3. You don’t need new/delete.

    Since you’re not going to be running multi-threaded, consider making the three vectors static. Hack, but might just work.

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

Sidebar

Related Questions

I have code that needs to loop and it will need to change the
I have an HTML page that has Javascript code. It needs to be rendered
I have an android app which has native code. The native code needs to
I have code which needs to do something like this There is a list
(I purchased a code signing cert from Thawte and have been going out of
I have a simple entity, Code, that I need to persist to a MySQL
I'm considering implementing one or two JSR APIs. I have not yet read the
We have a lot of jenkins tasks that process some date-dependent data, for example,
I understand that it is not possible to upload files using a regular Ajax
I have a project that requires me to process a lot (1000-10000) of big

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.