-
How to find the memory usage programatically?
Hi
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.
//myapp.cpp
#iclude <iostream.h>
long getMemStatus()
{
//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();
int x=10;
cout<<"\n3. current mem usage:"<<getMemstaus();
delete i;
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?
-
 Originally Posted by jonnin
dude dont post your cd key if thats what that is. Danny remove that?
I just have removed it.
Danny Kalev
-
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.
Danny Kalev
-
This May Help...
"Working Set Memory: " + (System.Environment.WorkingSet/1024).ToString() + "kb";
Similar Threads
-
By Methuselah in forum VB Classic
Replies: 2
Last Post: 07-13-2005, 10:30 AM
-
By dbsquared in forum .NET
Replies: 1
Last Post: 05-24-2005, 03:50 PM
-
By Jason Jakob in forum Java
Replies: 0
Last Post: 06-30-2002, 01:14 PM
-
Replies: 0
Last Post: 12-05-2001, 09:11 PM
-
Replies: 0
Last Post: 11-02-2001, 04:22 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|