sql - C++ bad memory alloc exception -


here gist of trying do. store files in sql table. table large 400 records each record stores file archive , size approximately 100mb each. recently, had change our encryption key.so writing threaded ( 5 threads ) code decrypt using legacy key , encrypt using new key.this each thread does

struct datatoreencrypt {      int id;      string data; } vector<datatoreencrypt> results;  // database open select id,filedata files id between 1 , 80 // 81-160 , on. // database connection close  // database connection open for(int i=0;i<results.size();i++ )  // results contain result of above query. {     string decrypted = legacydecryption(results[i].filedata);     string encrypted = newencryption(decrypted);      update files set filedata = encrypted id = results[i].id; } // database connection close 

the problem when trying this,i c++ bad_memory alloc exception , sql memory alloc exception. while reading through bad_memory alloc exception read c++ throws when compiler cannot allocate new memory. in case if helps, running on system 6gb ram ( have make work in 6gb ram minimum our product supports) , while process runs sqlserver.exe process takes close 4gb of ram space. please problem approach or anyways improved.

@thedark gave suggestion in last comment. if me , knew count in table or retrieve data count, similar following:

// database connection open for(int i=0;i<80;i++ )  // ...160...240...etc each thread {     string data;      select id,filedata files id = // 81-160 , on.      // data = filedata query      string decrypted = legacydecryption(data);     string encrypted = newencryption(decrypted);      update files set filedata = encrypted id = i; } // database connection close 

this reduce amount of memory used far , rid of struct. granted mean id's contiguous, i'm figuring since using table specific type of data.


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -