How to get physical memory size available to a process?
-
Hello folks! I used GlobalMemoryStatusEx[^] to get memory information. As the subject suggests, i am looking for the available physical memory my process may allocate, however, the
ullAvailPhys
member of MEMORYSTATUSEX[^] shows all the available memory bytes, not only the bytes allocatable by my process. So you understand, windows has a 2Gb (i know this can be increased to 3Gb but that's of no relevance right now) limit per process. So if my computer has 3Gb memory, my process allocates 1.5Gb, then i check the free memory size, i get 1.5G, but if i try to allocate that 1.5G, it will fail since only 0.5G is available to my process. I might be wrong, i am not sure, so please correct me if i am. So i figured, if i take the smaller value ofullAvailPhys
andullAvailVirtual
, this should give me the available physical mem for my process, but this is really a guess. So...can someone tell me how to do this correctly, or if this way is reliable? Thanks for any info in advance.> The problem with computers is that they do what you tell them to do and not what you want them to do. < > "It doesn't work, fix it" does not qualify as a bug report. < > Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <
-
Hello folks! I used GlobalMemoryStatusEx[^] to get memory information. As the subject suggests, i am looking for the available physical memory my process may allocate, however, the
ullAvailPhys
member of MEMORYSTATUSEX[^] shows all the available memory bytes, not only the bytes allocatable by my process. So you understand, windows has a 2Gb (i know this can be increased to 3Gb but that's of no relevance right now) limit per process. So if my computer has 3Gb memory, my process allocates 1.5Gb, then i check the free memory size, i get 1.5G, but if i try to allocate that 1.5G, it will fail since only 0.5G is available to my process. I might be wrong, i am not sure, so please correct me if i am. So i figured, if i take the smaller value ofullAvailPhys
andullAvailVirtual
, this should give me the available physical mem for my process, but this is really a guess. So...can someone tell me how to do this correctly, or if this way is reliable? Thanks for any info in advance.> The problem with computers is that they do what you tell them to do and not what you want them to do. < > "It doesn't work, fix it" does not qualify as a bug report. < > Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <
-
Well, the "default" implementation of new and malloc are mostly used for memory allocation as far as i know (what memory allocators 3rd party codes and windows API calls use is beyond me).
> The problem with computers is that they do what you tell them to do and not what you want them to do. < > "It doesn't work, fix it" does not qualify as a bug report. < > Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <
-
Well, the "default" implementation of new and malloc are mostly used for memory allocation as far as i know (what memory allocators 3rd party codes and windows API calls use is beyond me).
> The problem with computers is that they do what you tell them to do and not what you want them to do. < > "It doesn't work, fix it" does not qualify as a bug report. < > Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <
Default implementation of
new
of vc ismalloc
andmalloc
callsVirtualAlloc
. I checked how much memory's can be allocated on my pc with XP SP3. Available Phys. Memory: 1.7GB (from task manager) Available Virtual Memory: 2.0GB (fromGlobalMemoryStatusEx
) My program allocated: 1.5GB (byVirtualAlloc
ormalloc
) My program's Total Virtual Size: 1.5GB (from task manager) In general, total virtual memory space 2GB is sum of program own code size, some resources and other crt dll space size. So in this case, my program's size without heap should be around 500MB. (I think this strange.) I guess some other programs (like a anti virus program or so) or some Windows settings affected to this situation. -
Default implementation of
new
of vc ismalloc
andmalloc
callsVirtualAlloc
. I checked how much memory's can be allocated on my pc with XP SP3. Available Phys. Memory: 1.7GB (from task manager) Available Virtual Memory: 2.0GB (fromGlobalMemoryStatusEx
) My program allocated: 1.5GB (byVirtualAlloc
ormalloc
) My program's Total Virtual Size: 1.5GB (from task manager) In general, total virtual memory space 2GB is sum of program own code size, some resources and other crt dll space size. So in this case, my program's size without heap should be around 500MB. (I think this strange.) I guess some other programs (like a anti virus program or so) or some Windows settings affected to this situation.Thanks but i don't see how this answers my question...please clearify and sorry for my ignorance.
> The problem with computers is that they do what you tell them to do and not what you want them to do. < > "It doesn't work, fix it" does not qualify as a bug report. < > Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <