PDA

Click to See Complete Forum and Search --> : Free your memory after your game, how?


Arie
Mar 25th, 2002, 03:37 PM
Hi, Guys!

I have a question:

I have all kinds of variables: Integers, Longs, Arrays, hDC(Long), etc..

When I end my game, how and what should I clear from the memory?

I want my game to clear all the used memory, like it was before I started my game.

Thank you,
Arie.

Please visit: http://now.at/ariecoolsite

Fox
Mar 25th, 2002, 04:50 PM
Arrays:


Dim Temp() as Any
Redim Temp(Count) 'Create

Erase Temp 'Release


Classes:


Dim Temp() as Class
Set Temp = New Class 'Initialize

Set Temp = Nothing 'Release


For bitmaps/DCs see the other threads around...

kedaman
Mar 26th, 2002, 03:15 AM
garbage collection in OOP:
1. all object variables dereference when they are a) set to something else, b) set to nothing and c) run out of scope
2. objects are unloaded when their reference count is 0 (meaning no variable is refering to it)
3. all object unload when application terminates (this doesn't work with older versions of vb (or without a service pack) but this is only critical if you have objects refer to globally in modules)

GDI:
all GDI objects are deleted with DeleteObject() (bitmaps, brushes, pens, regions etc...)
all DC's are deleted with DeleteDC()
all DC's aquired with GetDC() are released with ReleaseDC()

if you are unsure about the api's you are using, look them up in MSDN for how to deallocate allocated resources

Arie
Mar 27th, 2002, 10:25 AM
That's all?
;) ;)
Thank you,
Arie.

Please check it out: http://now.at/ariecoolsite :( :( :(