473,656 Members | 2,793 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3809
"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 GlobalMemorySta tus function:

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

SIZE_T = c_ulong

class _MEMORYSTATUS(S tructure):
_fields_ = [("dwLength", DWORD),
("dwMemoryLengt h", DWORD),
("dwTotalPhy s", SIZE_T),
("dwAvailPhy s", SIZE_T),
("dwTotalPageFi le", SIZE_T),
("dwAvailPageFi le", SIZE_T),
("dwTotalVirtua l", SIZE_T),
("dwAvailVirtua lPhys", SIZE_T)]
def show(self):
for field_name, field_type in self._fields_:
print field_name, getattr(self, field_name)

memstatus = _MEMORYSTATUS()
windll.kernel32 .GlobalMemorySt atus(byref(mems tatus))
memstatus.show( )
-----

On my machine, it prints this:

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

See the MSDN docs for GlobalMemorySta tus 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
2403
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 Windows. Thanks Alex
5
2332
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 array will consume 500GB of memory. I need to break the operations up into managable chunks, so I dont consume all the available memory and get a segmentation fault. Its not a problem with numpy, I just need to intelligently slice up one of my...
7
3031
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: There is * Virtual memory you can allocate (VirtualAlloc) * Global memory you can allocate (GlobalAlloc) * Local memory you can allocate (LocalAlloc)
5
9006
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 alive threads my program could have each time the program runs. I use a number of threads in a simulation tool. Many thanks in advance. Best regards
6
8023
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 because the App-Domain could not be created. Error: 0x8007000e Not enough storage is
3
7124
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 in use. Even the peak memory usage of 1391MB is nowhere near the limit. I have 1.15GB physical memory ... remainder is System allocated Virtual Memory / Swap Space.
1
2749
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. Yet the query was rerun later when system was not as busy and it ran fine. I don't get it. Can anyone shed light on this? db2 8.1 fixpak 11 aix 5.3
1
1680
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 physical memory, not used yet by any application; 2. available means the total size of physical memory user application could use (exclude System Cache and Kernel Memory, which user application can not use), the user application may actually...
66
3676
by: karthikbalaguru | last post by:
Hi, Will 'free' return the memory Immediately to the OS ? Thx in advans, Karthik Balaguru
0
8297
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8717
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8600
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6162
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5629
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4150
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4300
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1930
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.