Subj : Re: largest memory block To : borland.public.cpp.borlandcpp From : maeder Date : Mon Mar 21 2005 05:46 pm "Mohsen" writes: > How can I find out how much memory is avalable, I'm sure that there are APIs that claim to provide that information, but ... > and how I can allocate that amount of memory? .... you can't do this. In general, the amount of memory available in the allocation isn't the same as the one you have just queried, because other tasks also allocate (and release) memory. IMHO, this means that the above mentioned APIs are rather useless. On operating systems where memory allocation is reliable (I think Windows are among them), the simplest approach is to try to allocate a certain amount of memory. If that fails, try to allocate less or report failure. On other operating systems, memory allocatino is not reliable (Linux is among these). A memory allocation can seem to succeed, but using that memory will then terminate the program. The only reliable strategy I can think of is to allocate the memory at program start and try to use it immediately to see if that works. .