473,396 Members | 1,775 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Available System Memory

Hi Folks,

This is hopefully an easy question. I would like to be able to check
available system memory on a WinXP machine from within python. I've
checked the docs in the win32 modules, read the Python Cookbook, and
tried the Python Essential Reference.

No luck.

Any ideas?

Many Thanks.

Bob

P.S. using v2.2

Jul 18 '05 #1
2 3804
"rtheiss" <rt*****@yahoo.com> writes:
Hi Folks,

This is hopefully an easy question. I would like to be able to check
available system memory on a WinXP machine from within python. I've
checked the docs in the win32 modules, read the Python Cookbook, and
tried the Python Essential Reference.

No luck.

Any ideas?

Many Thanks.

Bob

P.S. using v2.2

Here is a simple script which calls the GlobalMemoryStatus function:

-----
from ctypes import *
from ctypes.wintypes import DWORD

SIZE_T = c_ulong

class _MEMORYSTATUS(Structure):
_fields_ = [("dwLength", DWORD),
("dwMemoryLength", DWORD),
("dwTotalPhys", SIZE_T),
("dwAvailPhys", SIZE_T),
("dwTotalPageFile", SIZE_T),
("dwAvailPageFile", SIZE_T),
("dwTotalVirtual", SIZE_T),
("dwAvailVirtualPhys", SIZE_T)]
def show(self):
for field_name, field_type in self._fields_:
print field_name, getattr(self, field_name)

memstatus = _MEMORYSTATUS()
windll.kernel32.GlobalMemoryStatus(byref(memstatus ))
memstatus.show()
-----

On my machine, it prints this:

dwLength 32
dwMemoryLength 63
dwTotalPhys 535609344
dwAvailPhys 198139904
dwTotalPageFile 907055104
dwAvailPageFile 642375680
dwTotalVirtual 2147352576
dwAvailVirtualPhys 2117771264

See the MSDN docs for GlobalMemoryStatus to learn what the fields mean,
and <http://starship.python.net/crew/theller/ctypes> for the ctypes
module.

Thomas
Jul 18 '05 #2
"rtheiss" <rt*****@yahoo.com> wrote:

This is hopefully an easy question. I would like to be able to check
available system memory on a WinXP machine from within python. I've
checked the docs in the win32 modules, read the Python Cookbook, and
tried the Python Essential Reference.


The term "available system memory" basically has no meaning. On a virtual
memory system, you get as much as you need.

What problem are you really trying to solve?
--
- Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Alexandre | last post by:
Hi! I'd like to display available memory using Python but I haven't found the easy way to do it... Any idea please? Also I need a no specific OS function, as I plan to not only use it under...
5
by: Darren Dale | last post by:
I am doing linear algebra with large numarray. It is very efficient, but I have a small problem due to the size of my data. The dot product of a 10,000x3 double array with a 3x6,250,000 double...
7
by: Office Drone | last post by:
I'm a bit confused about memory usage, and for some reason I wasn't able to find a single point-of-call to get the amount of memory available. If we take, for instance, the Windows platform: ...
5
by: Kovan Akrei | last post by:
Hi, I wonder if it is possible to get hold of avaiable memory (only RAM) on a machine through .Net class library? I do not want to call windws API. I would like to use this to decide how many...
6
by: Christoph Schuster | last post by:
Hi ! We have a Liveserver running with ASP.NET 1.1.4322.0, whicht get a error after 3-5 days running: Source: ASP.NET 1.1.4322.0 Event ID: 1088 Description: Failed to execute request...
3
by: harry | last post by:
VS.NET 2002 (VB.NET) on Win XP. Is there a known bug regarding .NET reporting System.OutOfMemoryException when there is plenty of Virtual memory available? My TaskManager shows 1237M / 2181M...
1
by: sethwai | last post by:
Hi, We received an SQL 955 on a query. Since a snapshot showed that database wide memory was still available (high water mark was below max) I figured it was the SORTHEAP parm being too small. ...
1
by: George2 | last post by:
Hello everyone, I am using Windows Server 2003. I am confused about the available (memory) value under Physical Memory category. From search there are two meanings, 1. available means free...
66
by: karthikbalaguru | last post by:
Hi, Will 'free' return the memory Immediately to the OS ? Thx in advans, Karthik Balaguru
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.