On 26 Jul 2004 18:01:27 -0700,
fulbrighter2@yahoo.com (Office Drone)
wrote in comp.lang.c++:
[color=blue]
> I'm a bit confused about memory usage, and for some reason I wasn't
> able to find a single point-of-call to get the amount of memory
> available.
>
> If we take, for instance, the Windows platform:[/color]
This newsgroup discusses the C++ language which is defined by a
platform-independent ANSI/ISO/IEC standard. It does not take, for
instance, the Windows platform.
[color=blue]
> There is
> * Virtual memory you can allocate (VirtualAlloc)
> * Global memory you can allocate (GlobalAlloc)
> * Local memory you can allocate (LocalAlloc)
> * Heap memory you can allocate (HeapAlloc)[/color]
The four things you mention above are not part of the C++ language and
are not discussed here. You need a Windows programming group to talk
about them.
[color=blue]
> * Dynamic memory allocated via malloc/calloc
> * Memory allocated via new (which I presume is the same malloc)[/color]
You presume incorrectly, allocating memory via new or new [] is not at
all the same as allocating it with malloc/calloc/realloc.
[color=blue]
> Why are there so many different types of memory, and what is the best
> way to return the amount of memory available to allocs/new?[/color]
There are three types of memory that exist in a C++ program. Static,
automatic, and dynamic. The latter comes from new or
malloc/calloc/realloc. Whatever you get from the Windows API
functions is not a C++ issue.
[color=blue]
> What I need is to check on memory leaks in my program, since I'm
> writing my own memory manager.[/color]
After the huge list of memory allocation functions, both standard and
non-standard above, why do you think you need to write your own?
Aren't any of them good enough for you?
[color=blue]
> Also if there's an ANSI C function to return it cross-platform, it'll
> be great if anyone could hint on its name.[/color]
This is a C++ newsgroup, and there are significant parts of the
current ANSI/ISO C library that are not part of C++, so why are you
asking about C functions here?
In any case, no, there is no such function in standard C or C++. If
there were, it would be pretty useless in a modern multi-tasking
environment. By the time such a function returned a value to you, the
amount of available memory could have changed.
[color=blue]
> Any info from the monsters of C++ will be appreciated.[/color]
Start by reading the FAQ for this newsgroup, link in my signature.
--
Jack Klein
Home:
http://JK-Technology.Com
FAQs for
comp.lang.c
http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++
http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html