473,503 Members | 1,501 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Memory error in python

sangeeth
23 New Member
I have a very big python file which uses lists,tuples and dictionary.
The problem is that the program always crashes with Memory error.

Can anyone suggest how to solve this problem??
Jan 25 '07 #1
9 33154
Motoma
3,237 Recognized Expert Specialist
I have a very big python file which uses lists,tuples and dictionary.
The problem is that the program always crashes with Memory error.

Can anyone suggest how to solve this problem??
What is the environment you are using?
How big is the Python script getting?
What specific error messages are you getting?
Where in the code do you think things are going astray?
Are you performing any threading?

Usually, Python memory leaks are caused (seemingly intentionally) by the programmer. Python's data structures are large, and it is quite easy to waltz across 500 megs without realizing it.
Jan 25 '07 #2
Extremist
94 New Member
I have a very big python file which uses lists,tuples and dictionary.
The problem is that the program always crashes with Memory error.

Can anyone suggest how to solve this problem??
A few questions, otherwise there is no hope:
1. What is the error you are getting
2. What is the code you are using
3. What is the Python version you are using

I think it won't be a tuple,
Jan 25 '07 #3
sangeeth
23 New Member
A few questions, otherwise there is no hope:
1. What is the error you are getting
2. What is the code you are using
3. What is the Python version you are using

I think it won't be a tuple,
The error is Memory Error
The code is very big spanning some 41,000 lines, which I don't think will be useful if I share, but it uses a lot of lists and dictionaries
The Python version is 2.4.3

Can you help me now??
Maybe how to do better memory management in Python?
Jan 25 '07 #4
Motoma
3,237 Recognized Expert Specialist
The error is Memory Error
The code is very big spanning some 41,000 lines, which I don't think will be useful if I share, but it uses a lot of lists and dictionaries
The Python version is 2.4.3

Can you help me now??
Maybe how to do better memory management in Python?
When you get this error, does Python give you a Trackback? Try going into the code and looking at what is happening there.

You didn't answer my question as to how much memory the Python program is taking up when it starts running.

If you've written a 41000 line Python script, I expect you would have more than a cursory understanding of the language; do all of your classes have proper destructors? Are you properly disposing of dictionary entries, or entire dictionaries when you are done with the data they contain? What is the flow of your program; is it a big load operation, followed by a big process information followed by a big store operation, or is it getting caught up on a task that shouldn't have a problem with memory?
You haven't given me much to go on, the more helpful you are, the more helpful we can be.
Jan 25 '07 #5
Extremist
94 New Member
The error is Memory Error
The code is very big spanning some 41,000 lines, which I don't think will be useful if I share, but it uses a lot of lists and dictionaries
The Python version is 2.4.3

Can you help me now??
Maybe how to do better memory management in Python?
Well not to be mean or anything, I mean this in a very helpfull way,
but you are not saying anything. It's like saying: I have a typeError in 40000 lines of code. It really doensn't say anything.
And to tell you the truth, I got a Seg Fault until recently, when I discovered I havent installed a module or two.

I understand about the amount of code, perhaps you could write a little example app which will do the same and then it will be easier.

Answer the guy above's question as well
Keep me posted
Jan 25 '07 #6
bvdet
2,851 Recognized Expert Moderator Specialist
The error is Memory Error
The code is very big spanning some 41,000 lines, which I don't think will be useful if I share, but it uses a lot of lists and dictionaries
The Python version is 2.4.3

Can you help me now??
Maybe how to do better memory management in Python?
Memory leak? According to Python documentation http://docs.python.org/lib/module-gc.html:
To debug a leaking program call gc.set_debug(gc.DEBUG_LEAK). Notice that this includes gc.DEBUG_SAVEALL, causing garbage-collected objects to be saved in gc.garbage for inspection.
Jan 25 '07 #7
bartonc
6,596 Recognized Expert Expert
Here is a link to a discussion on range vs xrange. Good luck.
Jan 28 '07 #8
sudiptachatterjee
3 New Member
Okay, so I have run into the same problem, and the offending statement is this:

Expand|Select|Wrap|Line Numbers
  1.  tempHolder[followWord] = 0 
The tempHolder is a dictionary whose length can run into a really BIG number, because I am trying to go through an entire corpus of text and counting occurences of each word, so to say. Any ideas about how I can specify to Python that it needs to be prepared for such big lengths of the dictionary? Or is this a theoretical limit which I'll have to work around by creating smaller sub-dictionaries?

Thanks a lot in advance.
Apr 30 '07 #9
bartonc
6,596 Recognized Expert Expert
Okay, so I have run into the same problem, and the offending statement is this:

Expand|Select|Wrap|Line Numbers
  1.  tempHolder[followWord] = 0 
The tempHolder is a dictionary whose length can run into a really BIG number, because I am trying to go through an entire corpus of text and counting occurences of each word, so to say. Any ideas about how I can specify to Python that it needs to be prepared for such big lengths of the dictionary? Or is this a theoretical limit which I'll have to work around by creating smaller sub-dictionaries?

Thanks a lot in advance.
You should still post the entire error message to give a clue how to help.
Apr 30 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

3
3556
by: Bart Nessux | last post by:
def windows(): import os excludes = size_list = for root, dirs, files in os.walk('/'): total = for t in total: s = file(os.path.join(root,t)) size = s.read() size_list.append(size)
8
2470
by: Benjamin Scott | last post by:
Hello. I attempted to build a compound dictionary: len(Lst)=1000 len(nuerLst)=250 len(nuestLst)=500 Dict={}
1
7583
by: Srijit Kumar Bhadra | last post by:
Hello, Here are code snippets to create and access shared memory in Python with and without ctypes module. With regards, Srijit Filename : SharedMemCreate.py import msvcrt, mmap
7
2353
by: Dody Suria Wijaya | last post by:
Hi, I encountered a Memory Error Exception on using IMAP4 just like in Python documentation example, on a specially large email (10 MB). Any idea how to fix/circumvent this? >>> typ, data =...
11
7558
by: Hari Sekhon | last post by:
I do import zipfile zip=zipfile.ZipFile('d:\somepath\cdimage.zip') zip.namelist() then either of the two: A) file('someimage.iso','w').write(zip.read('someimage.iso'))
5
4930
by: shrikantm4u | last post by:
Hi, I am running a python script for some loop calculations and it is giving me memory error. Seems like my intermediate data is not releasing any memory and I get memory error. Any suggestions to...
2
1908
sangeeth
by: sangeeth | last post by:
python version 2.4.3 os - linux fc-4 I have a program which creates a lot of hashes and not make optimum use of memory.. I ran this program on a machine with below memory Mem: 9183196k...
4
10041
by: Robert LaMarca | last post by:
Hi, I am using numpy and wish to create very large arrays. My system is AMD 64 x 2 Ubuntu 8.04. Ubuntu should be 64 bit. I have 3gb RAM and a 15 GB swap drive. The command I have been trying...
2
3359
by: pyuser91 | last post by:
Hello, I hope someone can help. I am using Python 2.5.4 (under python(x,y) umbrella) on XP SP3, and running a grammatical evolution program that runs recursions on equations that grow via nested...
0
7203
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
7089
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...
0
7339
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
7463
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
5581
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,...
1
5017
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...
0
4678
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
1515
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 ...
1
738
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.