Page 1 of 1

Strings and Memory

Posted: Wed May 19, 2004 9:20 pm
by iancrt
I am having problems with the memory used in a program that does a lot of string manipulation. The guts of the program works like:

string2=bit_modified(string1)
string1=""
string3=bit_modified(string2)
string2=""
string4=bit_modified(string3)
string3=""

.....and so on, doing this multiple times in a loop 7 bytes at a time.
I thought that by setting the strings to "" (and re-dimensioning arrays to 0 elements) once finished with, it would free up memory, but it seems to leave the memory used at the original string length, even after procedures have terminated.
by the time it has dealt with about 500k of data - my page file is in the region of 2Gb!
I'm sure this is a windows thing. Is there another way to clear trhe memory being used while a program is running?

Posted: Wed May 19, 2004 9:43 pm
by tejon
maybe this could help viewtopic.php?t=6522

Posted: Wed May 19, 2004 9:56 pm
by Karbon
Haha!

Pay special attention to this quote in that post :

"Anyway. this topic is a nasty hack. I would recommend that no-one uses it ever."

Posted: Wed May 19, 2004 10:12 pm
by iancrt
Ouch!

Its an option though, thanks!

Had an idea I am testing now, got program running as:

dummy=bit_modified(string1)
string1=dummy
dummy=""
dummy=bit_modified(string1)
string1=dummy
dummy=""
dummy=bit_modified(string1)
string1=dummy
dummy=""
dummy=bit_modified(string1)
string1=dummy
dummy=""

same end result, just makes the code harder to read and follow (bad news once I sleep and next day have no idea what I was trying to do!).
I also had a huge 3x15x8 string array I was creating and releasing every pass - with the same values. I have moved this to shared and only create it once.
Now with only two vars the page file build up is much slower, and as a by product it has increased speed of the process by about 300%.

I can now process 3Mb before my swap file reaches the 2Gb limit. Unfortunatly I need to be able to process CD images files - 750Mb :( , other suggestions from anyone welcome.

Posted: Thu May 20, 2004 12:17 am
by tejon
use memory buffers see viewtopic.php?t=7171