Jump to content
Macro Express Forums

How to Detect a Program's Memory Usage


gibsonmantis

Recommended Posts

Is there a way to detect a program's memory usage? i.e. if a program uses more than 1,000kb of memory macro express will notify you?

 

Another way would be to use Task Manager. Here are the basic steps I would follow to buld the macro:

 

1) Enter your program name after prompting, and store it in a string variable, say T1.

 

2) R-click an empty space on the taskbar. Here, with a 1920 x 1200 screen, the rectangle on the extreme right (including the Time display from the Date/Time icon) gives a reliable result. So the following macro opens TM

 

// Get Memory usgae
Keystroke Speed: 10 Milliseconds
Mouse Speed: 1 Milliseconds
Mouse Move Screen 1900, 1190
Mouse Right Button Click
Delay 100 Milliseconds
Mouse Move Position -90, -60
Mouse Left Button Click
Delay 100 Milliseconds
Macro Return

 

<REM2:Get Memory usgae><SPKEY:0010><SPMSE:00001><MMS2:1900,1190><RCLK><MSD:100><MMP2:-90,-60><LCLK><MSD:100><MRETURN>

 

3) Click the Image Name column heading to sort alphabetically

 

4) Use a capture program hotkey (Snagit in my case) to capture all the text from that TM window

 

5) Paste it to NotePad or your preferred text editor

 

6) Use the Find or Search facility to locate the name of your program

 

7) Navigate across (4 columns in my case) to the Mem Usage column (in KB).

 

8) Copy that to clipboard and an integer variable, say N1

 

9) Compare N1 to your 'target', say 1000 KB and if necessary display an appropriate warning, etc.

 

10) Otherwise end the macro

 

11) Schedule it at whatever interval you think appropriate.

 

 

I see from a little googling that Mem Usage includes pages that can be shared by other processes, so you must be careful not to double-count. If you're trying to find out the combined memory usage of two processes that use a common DLL, for example, you can't simply add their Mem Usage values.

 

You don't say anything about why you're doing this or provide any background, so I'm not sure if my suggested approach is useful or not. I've assumed you want to take a 'snapshot' of a particular program's memory usage at short intervals? Presumably you've rejected the obvious idea of simply hitting Ctl+Alt+Del and checking that line in TM visually?

 

--

Terry, East Grinstead, UK

Link to comment
Share on other sites

Another way would be to use Task Manager. Here are the basic steps I would follow to buld the macro:

 

1) Enter your program name after prompting, and store it in a string variable, say T1.

 

2) R-click an empty space on the taskbar. Here, with a 1920 x 1200 screen, the rectangle on the extreme right (including the Time display from the Date/Time icon) gives a reliable result. So the following macro opens TM

 

// Get Memory usgae
Keystroke Speed: 10 Milliseconds
Mouse Speed: 1 Milliseconds
Mouse Move Screen 1900, 1190
Mouse Right Button Click
Delay 100 Milliseconds
Mouse Move Position -90, -60
Mouse Left Button Click
Delay 100 Milliseconds
Macro Return

 

<REM2:Get Memory usgae><SPKEY:0010><SPMSE:00001><MMS2:1900,1190><RCLK><MSD:100><MMP2:-90,-60><LCLK><MSD:100><MRETURN>

 

3) Click the Image Name column heading to sort alphabetically

 

4) Use a capture program hotkey (Snagit in my case) to capture all the text from that TM window

 

5) Paste it to NotePad or your preferred text editor

 

6) Use the Find or Search facility to locate the name of your program

 

7) Navigate across (4 columns in my case) to the Mem Usage column (in KB).

 

8) Copy that to clipboard and an integer variable, say N1

 

9) Compare N1 to your 'target', say 1000 KB and if necessary display an appropriate warning, etc.

 

10) Otherwise end the macro

 

11) Schedule it at whatever interval you think appropriate.

 

 

I see from a little googling that Mem Usage includes pages that can be shared by other processes, so you must be careful not to double-count. If you're trying to find out the combined memory usage of two processes that use a common DLL, for example, you can't simply add their Mem Usage values.

 

You don't say anything about why you're doing this or provide any background, so I'm not sure if my suggested approach is useful or not. I've assumed you want to take a 'snapshot' of a particular program's memory usage at short intervals? Presumably you've rejected the obvious idea of simply hitting Ctl+Alt+Del and checking that line in TM visually?

 

--

Terry, East Grinstead, UK

 

 

I really appreciate the reply.

 

I did want it to perform in the background, but this info is very helpfull.

 

I am currently developing software which utilizes several other programs to function. While my software is running I basically wanted this macro to notify me of how taxing it was on an average CPU and what sort of memory segmentation I was generating among the programs I am using.

 

I wonder if there is a way to access TM without manually pulling it up. I know that you can check if a program is running with Macro Express without pulling up TM. Hmm.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...