Author Topic: GLBasic Garbage Collector  (Read 3531 times)

Offline WPShadow

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1667
    • View Profile
    • http://lostrevenant.blogspot.com
GLBasic Garbage Collector
« 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.
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

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10759
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: GLBasic Garbage Collector
« Reply #1 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.
« Last Edit: 2014-May-14 by kanonet »

Offline WPShadow

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1667
    • View Profile
    • http://lostrevenant.blogspot.com
Re: GLBasic Garbage Collector
« Reply #2 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!!
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

Offline kanonet

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1142
    • View Profile
    • My GLBasic code archiv
Re: GLBasic Garbage Collector
« Reply #3 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.
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

Offline hardyx

  • Community Developer
  • Dr. Type
  • ******
  • Posts: 496
    • View Profile
Re: GLBasic Garbage Collector
« Reply #4 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.

« Last Edit: 2014-May-12 by hardyx »

Offline WPShadow

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1667
    • View Profile
    • http://lostrevenant.blogspot.com
Re: GLBasic Garbage Collector
« Reply #5 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
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

Offline kanonet

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1142
    • View Profile
    • My GLBasic code archiv
Re: GLBasic Garbage Collector
« Reply #6 on: 2014-May-12 »
Or simply
Code: (glbasic) [Select]
DIM aa[0]
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10759
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: GLBasic Garbage Collector
« Reply #7 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.
« Last Edit: 2014-May-14 by kanonet »

Offline WPShadow

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1667
    • View Profile
    • http://lostrevenant.blogspot.com
Re: GLBasic Garbage Collector
« Reply #8 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!!!
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