DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2005

    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.

    #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.

  2. #2
    Join Date
    Dec 2003
    dude dont post your cd key if thats what that is. Danny remove that?

  3. #3
    Join Date
    Nov 2003
    Quote 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

  4. #4
    Join Date
    May 2005
    you can overload opertor 'new' and 'delete' to determine how much memory are used in your app.

  5. #5
    Join Date
    Nov 2003
    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

  6. #6
    Join Date
    Aug 2005

    This May Help...

    "Working Set Memory: " + (System.Environment.WorkingSet/1024).ToString() + "kb";

Similar Threads

  1. DAO 3.5 vs 3.6 memory usage
    By Methuselah in forum VB Classic
    Replies: 2
    Last Post: 07-13-2005, 10:30 AM
  2. Memory Clean up
    By dbsquared in forum .NET
    Replies: 1
    Last Post: 05-24-2005, 03:50 PM
  3. Announcing a memory leak in javax.comm
    By Jason Jakob in forum Java
    Replies: 0
    Last Post: 06-30-2002, 01:14 PM
  4. Memory leak?
    By Jeff in forum Java
    Replies: 0
    Last Post: 12-05-2001, 09:11 PM
  5. help memory
    By kathy in forum Java
    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
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.