How to find the memory usage programatically?
I want to find what is the memory usage my application
eg. myapp.exe is the output of myapp.cpp.
when the exe is running it has to print current memory usages at certain execution point.
//this method has to find what is the size of memory usage in its current process space
void main ()
cout<<"\n1. current mem usage:"<<getMemstaus();
int *i=new int;
cout<<"\n2. current mem usage:"<<getMemstaus();
cout<<"\n3. current mem usage:"<<getMemstaus();
cout<<"\n4. current mem usage:"<<getMemstaus();
can somebody write the code for the function above getMemStatus()?
Also how to find what is heap mem size, stack mem size for my process programatically?
Last edited by Danny; 08-06-2005 at 10:54 PM.
dude dont post your cd key if thats what that is. Danny remove that?
I just have removed it.
Originally Posted by jonnin
you can overload opertor 'new' and 'delete' to determine how much memory are used in your app.
it's a very, very platform dependent issue. Most operating system these days use virtual memory management which means that the memory your program accesses is an alias of the real physical addresses of raw memory. This also means that you cannot tell whether the memory allocated by new is located on the RAM, the process's swap file, or the cache memory.
Depending on the platform you're using, there are certain APIs that can give you a clue but not much more than a clue because your process uses various sources of memory: its private heap, memory shared with one or more processes, memory mapped files etc.
This May Help...
"Working Set Memory: " + (System.Environment.WorkingSet/1024).ToString() + "kb";
By Methuselah in forum VB Classic
Last Post: 07-13-2005, 10:30 AM
By dbsquared in forum .NET
Last Post: 05-24-2005, 03:50 PM
By Jason Jakob in forum Java
Last Post: 06-30-2002, 01:14 PM
Last Post: 12-05-2001, 09:11 PM
Last Post: 11-02-2001, 04:22 PM
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL