473,769 Members | 7,646 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Program eating memory, but only on one machine?

Hi Everybody:

I'm having a difficult time figuring out a a memory use problem. I
have a python program that makes use of numpy and also calls a small C
module I wrote because part of the simulation needed to loop and I got
a massive speedup by putting that loop in C. I'm basically
manipulating a bunch of matrices, so nothing too fancy.

That aside, when the simulation runs, it typically uses a relatively
small amount of memory (about 1.5% of my 4GB of RAM on my linux
desktop) and this never increases. It can run for days without
increasing beyond this, running many many parameter set iterations.
This is what happens both on my Ubuntu Linux machine with the
following Python specs:

Python 2.4.4c1 (#2, Oct 11 2006, 20:00:03)
[GCC 4.1.2 20060928 (prerelease) (Ubuntu 4.1.1-13ubuntu5)] on linux2
Type "help", "copyright" , "credits" or "license" for more information.
>>import numpy
numpy.version .version
'1.0rc1'

and also on my Apple MacBook with the following Python specs:

Python 2.4.3 (#1, Apr 7 2006, 10:54:33)
[GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin
Type "help", "copyright" , "credits" or "license" for more information.
>>import numpy
numpy.version .version
'1.0.1.dev3435'
>>>

Well, that is the case on two of my test machines, but not on the one
machine that I really wish would work, my lab's cluster, which would
give me 20-fold increase in the number of processes I could run. On
that machine, each process is using 2GB of RAM after about 1 hour (and
the cluster MOM eventually kills them). I can watch the process eat
RAM at each iteration and never relinquish it. Here's the Python spec
of the cluster:

Python 2.4.4 (#1, Jan 21 2007, 12:09:48)
[GCC 3.2.3 20030502 (Red Hat Linux 3.2.3-49)] on linux2
Type "help", "copyright" , "credits" or "license" for more information.
>>import numpy
numpy.version .version
'1.0.1'

It also showed the same issue with the April 2006 2.4.3 release of python.

I have tried using the gc module to force garbage collection after
each iteration, but no change. I've done many newsgroup/google
searches looking for known issues, but none found. The only major
difference I can see is that our cluster is stuck on a really old
version of gcc with the RedHat Enterprise that's on there, but I found
no suggestions of memory issues online.

So, does anyone have any suggestions for how I can debug this problem?
If my program ate up memory on all machines, then I would know where
to start and would blame some horrible programming on my end. This
just seems like a less straightforward problem.

Thanks for any help,
Per
Jan 22 '07 #1
5 1775
Per B. Sederberg wrote:
Python 2.4.4c1 (#2, Oct 11 2006, 20:00:03)
[GCC 4.1.2 20060928 (prerelease) (Ubuntu 4.1.1-13ubuntu5)] on
[linux2 Type "help", "copyright" , "credits" or "license" for
more information.
Doesn't eat up.
Python 2.4.3 (#1, Apr 7 2006, 10:54:33)
[GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin
Type "help", "copyright" , "credits" or "license" for more
information.
Doesn't eat up.
Python 2.4.4 (#1, Jan 21 2007, 12:09:48)
[GCC 3.2.3 20030502 (Red Hat Linux 3.2.3-49)] on linux2
Type "help", "copyright" , "credits" or "license" for more
information.
Eats up memory
So, does anyone have any suggestions for how I can debug this
problem?
Have a look at the version numbers of the GCC used. Probably
something in your C code fails if it interacts with GCC 3.x.x.
It's hardly Python eating memory, this is probably your C
module. GC won't help here, since then you must add this into
your C module.
If my program ate up memory on all machines, then I would know
where to start and would blame some horrible programming on my
end. This just seems like a less straightforward problem.
GCC 3.x.x brings other runtime libs, than GCC 4.x.x, I would
check into that direction.

Wolfgang Draxinger
--
E-Mail address works, Jabber: he******@jabber .org, ICQ: 134682867

Jan 22 '07 #2

Wolfgang Draxinger <wdraxinger <atdarkstargame s.dewrites:
>
So, does anyone have any suggestions for how I can debug this
problem?

Have a look at the version numbers of the GCC used. Probably
something in your C code fails if it interacts with GCC 3.x.x.
It's hardly Python eating memory, this is probably your C
module. GC won't help here, since then you must add this into
your C module.
If my program ate up memory on all machines, then I would know
where to start and would blame some horrible programming on my
end. This just seems like a less straightforward problem.

GCC 3.x.x brings other runtime libs, than GCC 4.x.x, I would
check into that direction.
Thank you for the suggestions. Since my C module is such a small part of the
simulations, I can just comment out the call to that module completely (though I
am still loading it) and fill in what the results would have been with random
values. Sadly, the program still eats up memory on our cluster.

Still, it could be something related to compiling Python with the older GCC.

I'll see if I can make a really small example program that eats up memory on our
cluster. That way we'll have something easy to work with.

Thanks,
Per

Jan 22 '07 #3
I had a similar problem with an extension module on Solaris years ago.
My problem at that time:
I requested memory and released it and requested more memory in the next step
and so on.

The reason that the memory was eaten up:
An answer out of this group was that the operating system doesn't release the
memory space because it assumes you will need it soon again. The memory will
only be released with the end of the process.

The solution was always to request memory for the largest array the process will
demand and it worked for me.

Regards

Wolfgang

Per B.Sederberg wrote:
Wolfgang Draxinger <wdraxinger <atdarkstargame s.dewrites:
>>So, does anyone have any suggestions for how I can debug this
problem?
Have a look at the version numbers of the GCC used. Probably
something in your C code fails if it interacts with GCC 3.x.x.
It's hardly Python eating memory, this is probably your C
module. GC won't help here, since then you must add this into
your C module.
>> If my program ate up memory on all machines, then I would know
where to start and would blame some horrible programming on my
end. This just seems like a less straightforward problem.
GCC 3.x.x brings other runtime libs, than GCC 4.x.x, I would
check into that direction.

Thank you for the suggestions. Since my C module is such a small part of the
simulations, I can just comment out the call to that module completely (though I
am still loading it) and fill in what the results would have been with random
values. Sadly, the program still eats up memory on our cluster.

Still, it could be something related to compiling Python with the older GCC.

I'll see if I can make a really small example program that eats up memory on our
cluster. That way we'll have something easy to work with.

Thanks,
Per
Jan 22 '07 #4
Per B.Sederberg <persed <atprinceton.ed uwrites:
I'll see if I can make a really small example program that eats up memory on
our cluster. That way we'll have something easy to work with.
Now this is weird. I figured out the bug and it turned out that every time you
call numpy.setmember 1d in the latest stable release of numpy it was using up a
ton of memory and never releasing it.

I replaced every instance of setmember1d with my own method below and I have
zero increase in memory. It's not the most efficient of code, but it gets the
job done...
def ismember(a,b):
ainb = zeros(len(a),dt ype=bool)
for item in b:
ainb = ainb | (a==item)
return ainb

I'll now go post this problem on the numpy forums.

Best,
Per


Jan 22 '07 #5
Per B.Sederberg wrote:
Per B.Sederberg <persed <atprinceton.ed uwrites:
>I'll see if I can make a really small example program that eats up memory on
our cluster. That way we'll have something easy to work with.

Now this is weird. I figured out the bug and it turned out that every time you
call numpy.setmember 1d in the latest stable release of numpy it was using up a
ton of memory and never releasing it.
Hmm. With a recent checkout from SVN, I don't see any memory increase.
In [15]: from numpy import *

In [16]: ar1 = arange(1000000)

In [17]: ar2 = arange(3, 7)

In [18]: import itertools

In [19]: for i in itertools.count (1):
....: if not i % 1000:
....: print i
....: x = setmember1d(ar1 , ar2)

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco

Jan 22 '07 #6

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

Similar topics

14
3264
by: J. Campbell | last post by:
what happens to allocated memory when a program terminates before the memory is released. For example: int main(){ int* array; int a_size = 1000; array = new int; for(int i = 0; i < a_size; ++i){ if(i > (a_size/2)) return 0; //oops...ended before delete...is this a problem?
3
2005
by: Bobby Torkington | last post by:
Hi all I'm running version 4.0.16 on solaris 8 as the backend for a web site serving around 12 million pages impressions a month. The performance of the server is monitored using orcollator. I'm finding that the memory usage on the server remains pretty constant for weeks at a time at around 300 Meg but then every once in a while the size of the mysqld process jumps anywhere between another 50 and 250 Meg. It then stays at this new...
7
1527
by: Milk | last post by:
Anyone can help me to do this program, i will pay for it coz i really don't have time to do it and i need hand it in 22/04. Pls help me and reply about how much u want i pay for this program?? thanks a lot Here is the Question:: Improve the following (badly written) matrix multiplicationprogram and translate it into MIPs assembly language then assemble into machine language (hexadecimal representation). You may use a compiler to produce...
29
3960
by: tele-commuter | last post by:
Hi folks, I want to understand how exactly is an image(compiled c code and loaded into memory) stored in memory. What exactly is a linker script? I work with a lot of c code on a daily basis but I really don't understand :
62
17852
by: ivan.leben | last post by:
How can I really delete a preloaded image from memory/disk cache? Let's say I preload an image by creating an Image object and setting its src attribute to desired URL: var img = new Image(); img.src = ; Then I use the image a few more times by adding it into an Array object:
1
1693
by: gencode | last post by:
I have this bit if javascript and it animates an image well, the problem is that the more it runs the more memory it eats on the client machine. Can anyone help me make this not eat all avaliable memory, notice the recurrision, that may be it...is there a better way to it or free the last process ran...please help :D <script> // The following script implements rotating and fading the merchant logos. // Fade effect only in IE; degrades...
9
4537
by: Hemal | last post by:
Hi All, I need to know the memory required by a c program. Is there any tool/utility which can give me the memory usage in terms of DATA segment, TEXT segment, BSS segment etc. I am working on linux platform and my target is ARM processor. But i guess it should not matter. Actually i need to know both RAM & ROM usage.
20
2623
by: Francine.Neary | last post by:
I am learning C, having fun with strings & pointers at the moment! The following program is my solution to an exercise to take an input, strip the first word, and output the rest. It works fine when you give it 2 or more words, but when there's only 1 word the results vary depending on whether it's on Windows or Linux: under MSVC it displays no output (as it should); under gcc/Linux it instead gives "Segmentation fault". Any ideas...
19
6344
by: Zytan | last post by:
I want multiple instances of the same .exe to run and share the same data. I know they all can access the same file at the same time, no problem, but I'd like to have this data in RAM, which they can all access. It seems like a needless waste of memory to make them all maintain their own copy of the same data in RAM at the same time. What's the best way to achieve this? I've heard of memory mapped files, so maybe that's the answer. ...
0
9423
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
10214
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10048
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...
1
7410
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
6674
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
5304
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
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3563
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.