473,508 Members | 2,422 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

memory error with matplot

Hi,

I am using matplotlib with python to generate a bunch of charts. My
code works fine for a single iteration, which creates and saves 4
different charts. The trouble is that when I try to run it for the
entire set (about 200 items) it can run for 12 items at a time. On the
13th, I get an error from matplotlib that says it can't access data.
However, if I start the program at the point it failed before it works
fine and will create the charts for the next 12 before failing. I
assume that I am not closing the files properly somehow or otherwise
misallocating memory. I tried just reimporting pylab each iteration,
but that didn't help. This is the function that creates a chart:

#create and save the figure
def CreateFigure(state, facility, unit, SO2, increment, year, P99):
size = len(SO2)

#Create Plot
figure(1, figsize=(10,8))
bar(range(1, size+2), SO2, width=0.1, color='k')
grid(True)
xlim(0,size)
ylim(0, 1.1*SO2[-1])
ylabel('SO2 [lb/hr]')
heading = ConstructFigName(state, facility, unit, increment, year)
title(heading)

#set handles
xticklines = getp(gca(), 'xticklines')
xgridlines = getp(gca(), 'xgridlines')
xticklabels = getp(gca(), 'xticklabels')
yticklines = getp(gca(), 'yticklines')

#set properties
setp(xticklines, visible=False)
setp(xgridlines, visible=False)
setp(xticklabels, visible=False)
setp(yticklines, visible=False)

axhspan(P99, P99, lw=3, ec='r', fc='r')
ax = gca()
#P99 = str(P99)
P99 = '%0.1f' % P99
text(0.01, 0.95, '99th Percentile: '+P99+' lb/hr',
transform=ax.transAxes)

figpath = ConstructFigPath(state, facility, unit, increment, year)
savefig(figpath)
close()

Can you see the problem?

thanks,
-Lisa

Dec 5 '06 #1
1 4665
>>>>"lisa" == lisa engblom <li**********@gmail.comwrites:

lisaHi, I am using matplotlib with python to generate a bunch of
lisacharts. My code works fine for a single iteration, which
lisacreates and saves 4 different charts. The trouble is that
lisawhen I try to run it for the entire set (about 200 items) it
lisacan run for 12 items at a time. On the 13th, I get an error
lisafrom matplotlib that says it can't access data. However, if
lisaI start the program at the point it failed before it works
lisafine and will create the charts for the next 12 before
lisafailing. I assume that I am not closing the files properly
lisasomehow or otherwise misallocating memory. I tried just
lisareimporting pylab each iteration, but that didn't help.
lisaThis is the function that creates a chart:

There are a couple of things to try. First, on a long shot, does it
help to do

close(1)

instead if simply close(). I don't think it will but worth a try.

Second, I think there is a small leak in the tkcanvas, but not in
matplotlib proper. Do you need to display the graphs you are
creating, or do you merely want to save them? If the latter, simply
use the Agg backend

import matplotlib
matplotlib.use('Agg')

*before* you import pylab.

Finally, if you are still having troubles, post a complete,
free-standing, script to the matplotlib mailing list and we'll see if
we can replicate it.

You may also want to take a look at the FAQ on memory leaks:

http://matplotlib.sourceforge.net/faq.html#LEAKS

JDH
Dec 7 '06 #2

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

Similar topics

0
4357
by: Srijit Kumar Bhadra | last post by:
Hello, Here is some sample code with pywin32 build 203 and ctypes 0.9.6. Best regards, /Srijit File: SharedMemCreate_Mutex_win32all.py # This application should be used with...
1
4344
by: Attila.Rajmund.Nohl | last post by:
Hello! I'm using KAI C++ Compiler (KCC) Version 4.0d on Sparc Solaris 8 with Sun WorkShop 6 update 2 backend (KCC compiles C++ code to C than uses the Sun compiler to produce machine...
6
2279
by: Andrzej | last post by:
Used to read newsgroup for answers, now have to ask for them as well. I have an application (C#, .NET 1.1) that connects to local db on MSDE 2000 SP3a (using ADO from MDAC 2.71) on one side and...
25
2346
by: Zeng | last post by:
I finally narrowed down my code to this situation, quite a few (not all) of my CMyClass objects got hold up after each run of this function via the simple webpage that shows NumberEd editbox. My...
4
5968
by: Sean Shanny | last post by:
To all, Running into an out of memory error on our data warehouse server. This occurs only with our data from the 'September' section of a large fact table. The exact same query running over...
1
1538
by: dug | last post by:
Hi, I would like to do some real time signal processing with a graphical display and I would like your advice as to what I should use. I would like to be able to view the results and to change...
2
3640
by: Bigbadbradezee | last post by:
in matplot lib how do I generate two separate windows for separate plots. ie i have two contour plots i want to print out every time a program is run, but in separate windows. ...
6
4144
by: tgnelson85 | last post by:
Hello, C question here (running on Linux, though there should be no platform specific code). After reading through a few examples, and following one in a book, for linked lists i thought i would...
5
24599
by: kumarmdb2 | last post by:
Hi guys, For last few days we are getting out of private memory error. We have a development environment. We tried to figure out the problem but we believe that it might be related to the OS...
0
7224
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
7118
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...
1
7038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7493
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...
0
4706
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...
0
3192
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...
0
3180
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1550
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 ...
0
415
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...

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.