Results 1 to 17 of 17

Thread: X Variables > Free Them!

  1. #1

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

    Question X Variables > Free Them!

    Hi!

    I have in my game lots of variables, lots of LONG.
    How can I free all of them from the memory?

    Or What should I free?

    I want the memory back when my game is over, that's all.
    Is there a way? short way? long way? anyway?

    Tell me please, what are you doing when you have
    to exit your game...

    Before I run my game I have 80%,
    After it I have 54%.

    I have lots of INT & LONG.
    What should I do?

    Thank you,
    Arie.

  2. #2
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    Long vars are automatically released..

    do you use DCs? Or Controls (images, pictures,..)? You should clear the graphics yourself...

    use the ReleaseDC function to release DCs

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Israel
    Posts
    636
    I think I released all DCs.
    But anyway, I get less memory.
    Tell me what should I release...

    Thank you,
    Arie.

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    you should also delete all bitmaps, DC's don't eat much memory but the bitmaps will. deleteobject's the call
    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.

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Israel
    Posts
    636
    I have a LoadDC function.
    In it, it opens a new picture and then deletes it.
    It's working a 100+ times.
    Should it affect something?

    Thank you,
    Arie.

  6. #6
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221

    :confused:

    opens a new picture and deletes it? what for?
    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.

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Israel
    Posts
    636
    This function is used to load a DC from a file.

    Did you built any game? what variaibles did you free, and how?

    Thank you,
    Arie.

  8. #8
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    load a DC from a file - you don't load DC from files, they are on the screen, on windows or offscreen, but not in files. i guess the function you got loads a bitmap from a file and attaches and returns the device which is in the process attached to it. Variables don't need to be freed in vb, they will run out of scope sooner or later except if you terminate it either forcefully or manually using end statement. The bitmaps you GDI loads for you won't run out of scope, they will stay there until someone Deleteobjects them or turn off the computer. Paste the function here and i'll explain what you should do.
    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.

  9. #9
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    DeleteDC won't release the memory

  10. #10
    Fanatic Member
    Join Date
    Sep 1999
    Location
    Bethel, North Carolina, USA
    Posts
    987
    DeleteDC most certainly does remove the device context from memory if the DC was created with the CreateDC or CreateCompatibleDC function calls. If you have had problems in the past with memory and DeleteDC it is probably because you didn't select the original objects back into the DC.
    {Insert random techno-babble here}

    {Insert quote from some long gone mofo here}

  11. #11

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

    When I run the game in 80% free memory and it returns
    with 64% of free memory, Then I exit VB and then my memory is back. maybe when I'll have the EXE it will be OK?

    What do you do when you end a game?

    Thank you,
    Arie.

  12. #12
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    Did you use arrays? Try deleting them when you exit your game using Erase ArrayName
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  13. #13
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Once,again,DC's,don't,allocate,any,significant,memory,sorry,for,using,commas,instead,of,space,but,my ,keybord,is,on,a,bad,moodi'm,though,not,sure,if,you,mean,GDI-resources,because,they're,drained,if,you,don't,release,the,devices.Post,your,function,it,will,reveal ,the,flaw,immediately,include,module,or,global,variables,refered,in,it,if,there's,any.
    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.

  14. #14

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Israel
    Posts
    636
    I have a large array:
    Map(1 to 50, 1 to 37)

    And other small arrays.
    How should I free them?

    Thank you,
    Arie.

  15. #15
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    They will be freed as they run out of scope, or using erase statement. They won't be freed if you terminate your application.
    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.

  16. #16

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Israel
    Posts
    636
    So what should I write?

    Erase...

    How do I erase the arrays?

    Thank you,
    Arie.

    www.mag.up.co.il

  17. #17
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    VB Code:
    1. Erase MapArray



    Anyway, 50x37=1850 <- that's not even 2kbs, it's not gonna affect your computer much!

    It's probably something else.
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

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