GLBasic forum

Other languages => GLBasic - de => Topic started by: WPShadow on 2014-May-08

Title: GLBasic Garbage Collector
Post by: WPShadow on 2014-May-08
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.
Title: Re: GLBasic Garbage Collector
Post by: Kitty Hello on 2014-May-09
Speicher bleibt einfach. Bei Dim aa[0] wird er freigegeben.

Gesendet von meinem GT-N7100 mit Tapatalk

EDIT by kanonet: restored formatting.
Title: Re: GLBasic Garbage Collector
Post by: WPShadow on 2014-May-09
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!!
Title: Re: GLBasic Garbage Collector
Post by: kanonet on 2014-May-09
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.
Title: Re: GLBasic Garbage Collector
Post by: hardyx on 2014-May-12
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.

Title: Re: GLBasic Garbage Collector
Post by: WPShadow on 2014-May-12
Then the solution is

Code: (glbasic) [Select]
FOREACH a IN aa[]
DELETE a
NEXT

Thank you all for the info  =D
Title: Re: GLBasic Garbage Collector
Post by: kanonet on 2014-May-12
Or simply
Code: (glbasic) [Select]
DIM aa[0]
Title: Re: GLBasic Garbage Collector
Post by: Kitty Hello on 2014-May-14
Delete does NOT free the internal memory. Only DIM aa[0] does.

Gesendet von meinem GT-N7100 mit Tapatalk

EDIT by Kanonet: restored formatting.
Title: Re: GLBasic Garbage Collector
Post by: WPShadow on 2014-May-15
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!!!