c# - For Loop - Out of Memory Exception -


Actually, I would like to combine 9 digits with such as DB to in an encrypted format < / Code>

Therefore, I have used a very basic algorithm for encryption and the idea of ​​using it for 99 9, 999,999 for loop DataTable and wholesale copies for SQL

My program goes like this:

  Datatale DtData = new datatale (); DtData.Columns.Add ("ENCRYPTED_DATA", typef (string)); {String number = i.ToString ("D9") for (Int64 i = 1; i & lt; = 999999999; i ++); String encrypt = encrypt decrypt. Encrypt (number); DtData.Rows.Add (encrypted); If (i% 100000 == 0) {GC. Compiler (GC Max Generation, GCC Lockdownload Forge); }}  

But my problem is that I am getting out of memory exception after some time.
can there save the garbage collection or any other way and memory consumption?
In fact, Code of GC.collect is not in reducing memory usage as I can see in the Task Manager.

My PC RAM is 16 GB and estimated time is taken for processing 8,000,000 records is 7 minutes . After taking 16 GB, it is according to OutOfMemoryException Task Manager.
Is there any way to reduce memory consensus and to completely execute my forloop?

line

  gc Compiler (GC Max Generation, GCC LockShod Forge);  

does not free the data already present in the DataTable DtData . I do not know the size of the stars you have created, but you are creating thousands of strings and adding them to DataTable DtData

DtData in this strip Within the loop is not eligible for garbage collection.

From time to time, the database contains the following numbers in

  Datatale DtData = new datatile (); DtData.Columns.Add ("ENCRYPTED_DATA", typef (string)); {String number = i.ToString ("D9") for (Int64 i = 1; i & lt; = 999999999; i ++); String encrypt = encrypt decrypt. Encrypt (number); DtData.Rows.Add (encrypted); // Based on the needs of your performance test and application, this number changes if (i% 100000 == 0) {// //GC.Collect (GC MaxGenction, GCC Lockforward Forge) instead of this; // Change and refresh your Datatable DoSomeDatabaseCommitHere (DtData); Dtdata = new datatable (); }}  

You can also work with DataTable for more options and asynchronous uploads.


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -