Results 1 to 4 of 4

Thread: Free your memory after your game, how?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Israel
    Posts
    636

    Question Free your memory after your game, how?

    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

  2. #2
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    Arrays:

    VB Code:
    1. Dim Temp() as Any
    2. Redim Temp(Count) 'Create
    3.  
    4. Erase Temp 'Release

    Classes:

    VB Code:
    1. Dim Temp() as Class
    2. Set Temp = New Class 'Initialize
    3.  
    4. Set Temp = Nothing 'Release

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

  3. #3
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Israel
    Posts
    636
    That's all?

    Thank you,
    Arie.

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width