-
clearing memory dumps
I have develop an app that is communicating with a modem and is parsing large strings coming from modem the problem is that as the app continue to parse strings the memory that the program is 'eating' grows enormously with result 'memory overflow' .So i though clearing those strings. Easy to do cuase the modem is sending strings only when is ringing so i though by clearing the string just b4 modem ring should clear the memory too but it doesn't . Any ideas?
thnks
ps: i have already used a concat class for appending parsed strings to vars
-
IF your code looks like this even in the class:
Code:
somebigstring = somebigstring & littlestring
That's your memory problem. If Len(somebigstring) = 4MB it takes 8MB of memory to concatenate littlestring because concatenation requires two copies of somebigstring.
Do something like this instead:
Code:
Dim arr() as string
.........
Redim Preserve arr(ubound(arr)+1)
arr(ubound(arr) ) = littlestring
' then when you need the big string do this:
somebigstring = Join(arr)
Erase arr
-
It sounds to me like the problem is possibly that you are creating many instances of your class and not destroying them afterwards.
As far as I am aware str = "" should free the memory that the string was using (unless you have intentionally declared the strings as fixed length).
-
because the project has become too large and too complicated its difficult to use the concat class in all the vars so I wanted to know if there is a another way to clear all trashes from memory