If a allocate Memory for Structures, which contains strings and then free the memory again ... the memory of the strings are still allocated.
Check this code:
Code: Select all
Macro PAUSE(MSG = "Check Memory in Taskmanager!")
MessageRequester("WAIT",MSG)
EndMacro
#TestSize = 1024*1024
Structure StructWithStrings
s1.s
x.l
s2.s
EndStructure
Global Dim aPointers(#TestSize)
*PStruct.StructWithStrings
PAUSE("Array allocated!")
For i = 0 To #TestSize
aPointers(i) = AllocateMemory(SizeOf(StructWithStrings))
Next i
PAUSE("Memory for Structures allocated")
For i = 0 To #TestSize
*PStruct = aPointers(i)
*PStruct\s1 = "test s1: " + Str(i)
*PStruct\s2 = "test s2: " + Str(i)
Next i
PAUSE("Structures filled With strings")
For i = 0 To #TestSize
FreeMemory(aPointers(i))
Next i
PAUSE("Memory free again??? NO!!!")
Would it be possible to make this intern function open, so I can use a PB-function to free strings in structures.
Example:
Code: Select all
; ... code see previous example
PAUSE("Memory for Structures allocated")
For i = 0 To #TestSize
*PStruct = aPointers(i)
*PStruct\s1 = "test s1: " + Str(i)
*PStruct\s2 = "test s2: " + Str(i)
Next i
PAUSE("Structures filled With strings")
For i = 0 To #TestSize
FreeStructureStrings(*PStruct) ; <<<< NEW PB FUNCTION
FreeMemory(aPointers(i))
Next i
PAUSE("Memory free again??? NO!!!")
Is this possible????
cu, helpy