Hey,
wie funktioniert in GLBasic eigentlich der Garbage Collector?
Nehmen wir an ich habe eine verschachtelte Struktur von 3 Types wie z.B. hier:
TYPE a
bb[] as b
ENDTYPE
TYPE b
cc[] AS c
ENDTYPE
TYPE c
ENDTYPE
GLOBAL aa[] AS a
Wenn ich aa[] mit einer FOREACh - Schleife lösche, werden dann auch bb[] und cc[] aus dem Speicher geworfen oder muss ich die getrennt entfernen? Also "oldschool C" ...
LG
W.
Speicher bleibt einfach. Bei Dim aa[0] wird er freigegeben.
Gesendet von meinem GT-N7100 mit Tapatalk
EDIT by kanonet: restored formatting.
Ok, in dem Fall dann löse ich es so:
FOREACH a IN aa[]
FOREACH b IN bb[]
FOREACH c IN cc[]
DELETE c
NEXT
DELETE b
NEXT
DELETE a
NEXT
Danke dir für die Info!!
Nee, ich glaube da hast du ihn falsch verstanden (blöder bb-code hat seinen Post formatiert), ein DIM a[0]
sollte allen Speicher freigeben.
GLB Types are like classes in C++ or Java. If you delete the element a[index], the TYPE automatically deletes the b[] array and the b TYPE deletes the c[] array.
Then the solution is
FOREACH a IN aa[]
DELETE a
NEXT
Thank you all for the info =D
Or simply DIM aa[0]
Delete does NOT free the internal memory. Only DIM aa[0] does.
Gesendet von meinem GT-N7100 mit Tapatalk
EDIT by Kanonet: restored formatting.
Good to know... I've arround 400mb data in the memory and after the "export" to a textfile it would be a good thing to free the memory again...
Thank you for the info!!!