Space Function.

Discussion in 'Programming' started by vivek_master146, Sep 28, 2009.

  1. #1
    I have heard from many people that this code would free up RAM when PC becomes sluggish:-

    FreeMem=Space(64000000) (saving it as .vbs)

    How its possible ?

    I think this code will just allocate 64 MB to FreeMem variable. So more 64 MB more will be occupied.

    Please explain.
     
    vivek_master146, Sep 28, 2009 IP
  2. ohteddy

    ohteddy Member

    Messages:
    128
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    28
    #2
    Looks fishy to me.
     
    ohteddy, Sep 28, 2009 IP
  3. vivek_master146

    vivek_master146 Peon

    Messages:
    134
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Does it really free up the RAM. ?
     
    vivek_master146, Oct 1, 2009 IP
  4. frantech

    frantech Greenhorn

    Messages:
    96
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    20
    #4
    Hey there,

    Well, it's possible if you're REALLY low on RAM, what can happen is it uses up that memory, pushing other things that were using that memory into the pagefile. The page file is really slow though so it isn't really 'free' memory, it's 'free' at the cost of one of your programs running like a slug afterwards.

    Thanks :)

    Francisco
     
    frantech, Oct 2, 2009 IP
  5. caprichoso

    caprichoso Well-Known Member

    Messages:
    433
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    110
    #5
    Yes, it is possible. But it is also a trick.

    The operating system is responsible for administering memory. Applications ask for memory when needed, and then release the ram they were given when no longer needed. In turn the operating system caches returned memory just in case the same applications needs it again. Cached memory doesn't count as free memory. But, if a new application ask for all RAM left, the operating system will give the cached RAM too.

    This script asks for memory, releases it and quits. Moving a certain amount of RAM from the cache to the free memory pool. You gain nothing and, if an already running application needs memory again there will be an extra cost for administering RAM.

    If you are running low of memory, things get worst as Francisco said before.

    Take a look:
    
    sauron:~# free
                 total       used       free     shared    buffers     cached
    Mem:        483048     479400       3648          0       3696     215776
    -/+ buffers/cache:     259928     223120
    Swap:      1445808      29904    1415904
    
    Code (markup):
    There is a total of 483MB of physical RAM, 479MB used, 4MB free and 215MB cached. A new process can take up to 219MB before system starts swapping.

    REALLY FREE RAM = FREE RAM + CACHED RAM
     
    caprichoso, Oct 2, 2009 IP