GLBasic Garbage Collector

Previous topic - Next topic

WPShadow

Hey,

wie funktioniert in GLBasic eigentlich der Garbage Collector?

Nehmen wir an ich habe eine verschachtelte Struktur von 3 Types wie z.B. hier:

Code (glbasic) Select


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.
AMD X2 4600, 2 GB Ram, ATI X1950 XTX, XP PRO SP2: GLB Premium 10.beta_dingsi, <(´.´<) Kirby Dance (>`.`)>
http://lostrevenant.blogspot.com
alea iacta est

Kitty Hello

#1
Speicher bleibt einfach. Bei Dim aa[0] wird er freigegeben.

Gesendet von meinem GT-N7100 mit Tapatalk

EDIT by kanonet: restored formatting.

WPShadow

Ok, in dem Fall dann löse ich es so:

Code (glbasic) Select

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!!
AMD X2 4600, 2 GB Ram, ATI X1950 XTX, XP PRO SP2: GLB Premium 10.beta_dingsi, <(´.´<) Kirby Dance (>`.`)>
http://lostrevenant.blogspot.com
alea iacta est

kanonet

Nee, ich glaube da hast du ihn falsch verstanden (blöder bb-code hat seinen Post formatiert), ein
Code (glbasic) Select
DIM a[0] sollte allen Speicher freigeben.
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

hardyx

#4
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.


WPShadow

Then the solution is

Code (glbasic) Select

FOREACH a IN aa[]
DELETE a
NEXT


Thank you all for the info  =D
AMD X2 4600, 2 GB Ram, ATI X1950 XTX, XP PRO SP2: GLB Premium 10.beta_dingsi, <(´.´<) Kirby Dance (>`.`)>
http://lostrevenant.blogspot.com
alea iacta est

kanonet

Or simply
Code (glbasic) Select
DIM aa[0]
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

Kitty Hello

#7
Delete does NOT free the internal memory. Only DIM aa[0] does.

Gesendet von meinem GT-N7100 mit Tapatalk

EDIT by Kanonet: restored formatting.

WPShadow

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!!!
AMD X2 4600, 2 GB Ram, ATI X1950 XTX, XP PRO SP2: GLB Premium 10.beta_dingsi, <(´.´<) Kirby Dance (>`.`)>
http://lostrevenant.blogspot.com
alea iacta est