amount of allocated memory...

This is a discussion on amount of allocated memory... within the Windows Programming forums, part of the Platform Specific Boards category; Hello. Is there any way (any API support) to find out how much memory has my application allocated in any ...

  1. #1
    Registered User lobo's Avatar
    Join Date
    Oct 2001
    Posts
    71

    amount of allocated memory...

    Hello.
    Is there any way (any API support) to find out how much memory has my application allocated in any moment? I have one that uses a lot of malloc()'s and free()'s. I got idea that i could use a global variable to count them all as they are performed, but i'd like to know if there is not better (simplier, possibly more accurate) way to archieve this

  2. #2
    Registered User
    Join Date
    Dec 2001
    Posts
    70
    Try VirtualQuery

    BTW you can't get the exact size of reserved memory by simply counting all the allocations up, because when the allocation is made, the system often reserves greater space than is requested.

  3. #3
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    If using the win32 api try looking at its memory functions

    GlobalAlloc() LocalAlloc() GlobalRealloc() GlobalHandle() GlobalLock() ect.

    GlobalSize() will tell you the amount actually allocated. Try keeping count each time you alloc and free adjust the total. Write a function to do it for you (with a static as the total).
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Determing the amount of change(money)
    By Kyeong in forum C Programming
    Replies: 11
    Last Post: 09-30-2008, 04:36 PM
  2. Memory allocated
    By saswatdash83 in forum C Programming
    Replies: 2
    Last Post: 07-15-2008, 02:28 AM
  3. problem with data in allocated memory
    By supi in forum C Programming
    Replies: 3
    Last Post: 06-09-2008, 02:06 AM
  4. Question regarding Memory Leak
    By clegs in forum C++ Programming
    Replies: 29
    Last Post: 12-07-2007, 12:57 AM
  5. Is it necessary to write a specific memory manager ?
    By Morglum in forum Game Programming
    Replies: 18
    Last Post: 07-01-2002, 01:41 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21