Fab's AutoBackup Out of memory error

That piece of code may not be that good since I have only been able to add only 100000 more items regarding yesterday's test with just the tstringlist. That said, 12 millions files should be enough for all machines, this is an insane number of files.
 
Instead of using arrays to string, you should use arrays of pointers to null-terminated strings. Pointers are much smaller than strings, so it dramitally decreses the size of array and you don't have to copy as much data when you resize the array.

It should be something like
CopyList Array : array of PChar;
Use StrAlloc(size) and StrDispose(pointer) to allocate memory for each string. You'll have to keep count of current array size and number of used slots, so that you don't have memory leaks.
 
Instead of using arrays to string, you should use arrays of pointers to null-terminated strings. Pointers are much smaller than strings, so it dramitally decreses the size of array and you don't have to copy as much data when you resize the array.

It should be something like
CopyList Array : array of PChar;
Use StrAlloc(size) and StrDispose(pointer) to allocate memory for each string. You'll have to keep count of current array size and number of used slots, so that you don't have memory leaks.
How would you code that?
 
http://stackoverflow.com/questions/...-elements-of-array-of-pchar-be-freed-manually
http://stackoverflow.com/questions/14794431/how-to-pass-string-to-an-array-of-pansichar

By the way you can use PAnsiChar(encoded in UTF-8) instead of PChar, so that your memory footprint would be reduced by 50%.
Delphi apparently has builtin UTF-8 conversion functions, so you can play with them.
http://stackoverflow.com/questions/2697843/storing-utf-8-string-in-a-unicodestring
If it doesn't work you can rely on Win32API(https://msdn.microsoft.com/en-us/library/windows/desktop/dd319072(v=vs.85).aspx).
 
I am trying with PAnsiChar instead of String and I must say WOW! It has been adding 4 millions lines and the whole program's process is only using 140 MB so far! With so low RAM use, I can re-enable the debugging action list back. A huge thank you!
 
Something doesn't add up.
That's only 36.7 bytes per string(140*1024*1024/4 000 000).

The string that you posted is 146 characters long.
 
Yes that is wrong. I have tried to save the list to a text file and I only get one character per line. Let's go back to start :/
 
Back
Top