Strings and Memory

Everything else that doesn't fall into one of the other PB categories.
iancrt
User
User
Posts: 12
Joined: Sun May 18, 2003 10:55 am
Location: UK, LEEDS

Strings and Memory

Post 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?
tejon
User
User
Posts: 29
Joined: Sat May 17, 2003 12:38 am

Post by tejon »

maybe this could help viewtopic.php?t=6522
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Post 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."
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
iancrt
User
User
Posts: 12
Joined: Sun May 18, 2003 10:55 am
Location: UK, LEEDS

Post 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.
tejon
User
User
Posts: 29
Joined: Sat May 17, 2003 12:38 am

Post by tejon »

use memory buffers see viewtopic.php?t=7171
Post Reply