Anon.
Anon.

Reputation: 43

How would I discover the memory used by an application through a python script?

Recently I've found myself testing an aplication in Froglogic's Squish, using Python to create test scripts. Just the other day, the question of how much memory the program is using has come up, and I've found myself unable to answer it. It seems reasonable to assume that there's a way to query the os (windows 7) API for the information, but I've no idea where to begin. Does anyone know how I'd go about this?

Upvotes: 1

Views: 269

Answers (3)

Harri Porten
Harri Porten

Reputation: 1

Remember that Squish allows remote testing of the application. A system parameter queried via Python directly will only apply to the case of local testing.

An approach that works in either case is to call the currentApplicationContext() function that will give you a handle to the Application Under Test. It has a usedMemory property you can query. I don't recall which process property exactly is being queried but it should provide a rough indication.

Upvotes: 0

jspcal
jspcal

Reputation: 51934

this answer has some code (for windows and unix):

Total memory used by Python process?

on win, you are checking Win32_PerfRawData_PerfProc_Process and on linux it's /proc/pid/status (or ps)

Upvotes: 2

Alix Axel
Alix Axel

Reputation: 154673

In command line: tasklist /FO LIST and parse the results?

Sorry, I don't know a Pythonic way. =P

Upvotes: -1

Related Questions