473,409 Members | 2,006 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,409 software developers and data experts.

PSP crashes when my python program

I am coding for the PSP and I have an RSS reader that will show images and stuff. the proplem is that the reader will crash after displaying i think 10 pages with images on them. here is the part of my code that blits the image to a layer, which will later be blitted to the screen.

Expand|Select|Wrap|Line Numbers
  1. for idx, wc in enumerate(c):
  2.             if wc == "&": #finds out if it the beginning of a '<'
  3.                 activi=0
  4.             if wc == "l" and activi==0:
  5.                 activi=2
  6.             if wc=="*" and activi==2: #previously marked each image with a '*'
  7.                 url=c.replace('"', '').replace('*','')
  8.                 jpg=url.find('jpg')
  9.                 png=url.find('png')
  10.                 gif=url.find('gif')
  11.                 exten='mesa'
  12.                 if jpg>=0: #only support jpg and png
  13.                     exten='jpg'
  14.                     name=url[jpg-15:jpg-2]
  15.                 if png>=0:
  16.                     exten='png'
  17.                     name=url[png-10:png-2]
  18.                 if gif>=0:
  19.                     exten='gif'
  20.                     name='mesa'
  21.                 if exten != 'gif' and exten != 'mesa': #blit the image to the screen
  22.                     name=name.replace("/", '')
  23.                     temp=psp2d.Image('temp/%s' % name + '.' + exten)
  24.                     locx=(480-(temp.width))/2
  25.                     dy2+=16
  26.                     bg.blit(temp, 0, 0, temp.width, temp.height, locx, dy2+dy)
  27.                     dy2 += temp.height
  28.                     temp=None #clear out the variables (thought this could help)
  29.                     name=None
  30.                     url=None
  31.                     exten=None
  32.                     png=None
  33.                     jpg=None
  34.                     gif=None
if I do this:

Expand|Select|Wrap|Line Numbers
  1. for idx, wc in enumerate(c):
  2.             if wc == "&": #finds out if it the beginning of a '< in the xml page'
  3.                 activi=0
  4.             if wc == "l" and activi==0:
  5.                 activi=2
  6.             if wc=="*" and activi==2: #previously marked each image with a '*'
  7.                 url=c.replace('"', '').replace('*','')
  8.                 jpg=url.find('jpg')
  9.                 png=url.find('png')
  10.                 gif=url.find('gif')
  11.                 exten='mesa'
  12.                 if jpg>=0: #only support jpg and png
  13.                     exten='jpg'
  14.                     name=url[jpg-15:jpg-2]
  15.                 if png>=0:
  16.                     exten='png'
  17.                     name=url[png-10:png-2]
  18.                 if gif>=0:
  19.                     exten='gif'
  20.                     name='mesa'
  21.                 #if exten != 'gif' and exten != 'mesa': #blit the image to the screen
  22.                   #  name=name.replace("/", '')
  23.                     #temp=psp2d.Image('temp/%s' % name + '.' + exten) 
  24.                     #locx=(480-(temp.width))/2
  25.                     #dy2+=16
  26.                     #bg.blit(temp, 0, 0, temp.width, temp.height, locx, dy2+dy)
  27.                     #dy2 += temp.height
  28.                     #temp=None #clear out the variables (thought this could help)
  29.                     #name=None
  30.                     #url=None
  31.                     #exten=None
  32.                     #png=None
  33.                     #jpg=None
  34.                     #gif=None
then i can view every page without crashes (and without images). but i need images.

It doesnt matter what order i go in. i can do (numbers represent articles)
1,2,3,4,5,6,7,8,9,CRASH
1,2,1,2,1,2,1,2,1,CRASH
1,2,3,4,3,4,3,2,3,CRASH

say page 0 has no images, then i can do this 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,CRASH
so it lasts only if 10 pages with images have been displayed. I did a memory test, and there says constant (well fluxates around 15mb's) so there is no leak..

so i am really stumped on why this wont work, can someone help me out?
Jul 9 '07 #1
3 2659
bartonc
6,596 Expert 4TB
I'm guessing (because you have not shown your import statements) that one or some of the modules in are written in C. It sounds like a memory allocation issue (not usually a problem in python itself).
Jul 9 '07 #2
I'm guessing (because you have not shown your import statements) that one or some of the modules in are written in C. It sounds like a memory allocation issue (not usually a problem in python itself).
i think your right, because if i replace the
Expand|Select|Wrap|Line Numbers
  1. temp = psp2d.Image('temp/%s' % name + '.' + exten)
with
Expand|Select|Wrap|Line Numbers
  1. temp = psp2d.Image('holder.png')
it works fine. so replacing it with a constant image doesnt cause it to crash... and i tried it on my pc and works flawlessly. and when i looked at the core tracebacks, i kept getting errors about unable to make a proper traceback because too many files were open. Ill tell the dev. and hopefully it can be fixed soon.
Jul 10 '07 #3
ok, this just isnt making any sense to me now.

i am using a keyboard input library for the psp called danzeff (some of you familiar with the psp probably know about it) well, when i load the keyboard (it displays it on screen allowing for input), it should lessen the ammount of pages i can see shouldnt it? since it takes roughly 8 image files to be loaded into the gfx memory (psp2d.Image()) and then it clears them out the same way i did when you close the keyboard(=None). if i comment out the keyboard i can view 10 pages, but if i dont comment out the keybaord part, and call it up, i still can still view 10 pages. shouldnt i only be able to view 2 since 8 extra image files were loaded into memory and cleared out of memory the exact same way that I clear out my temporary images? the reason i ask, is if i add this:
Expand|Select|Wrap|Line Numbers
  1. lalala=psp2d.Image('static.png')
before this:
Expand|Select|Wrap|Line Numbers
  1. temp=psp2d.Image('temp/%s' % name + '.' + exten)
to make this:
Expand|Select|Wrap|Line Numbers
  1. lalala=psp2d.Image('static.png')
  2. temp=psp2d.Image('temp/%s' % name + '.' + exten)
I can only view 9 pages, since 1 more image was loaded...
if someone wants to help me, i can send you the complete program (i dont want to post it here because of size), but this is driving me nuts.
Jul 12 '07 #4

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

Similar topics

3
by: srijit | last post by:
Hello, Any idea - why the following code crashes on my Win 98 machine with Python 2.3? Everytime I run this code, I have to reboot my machine. I also have Win32all-157 installed. from Tkinter...
0
by: travis ray | last post by:
Hi, I have an extension in which a file object is created in python and passed down to a c extension which attempts to read from it or write to it. Writing to the file pointer seems to work...
2
by: robert | last post by:
When employing complex UI libs (wx, win32ui, ..) and other extension libs, nice "only Python stack traces" remain a myth. Currently I'm hunting again a rare C-level crash bug of a Python based...
6
by: robert | last post by:
I get python crashes and (in better cases) strange Python exceptions when (in most cases) importing and using cookielib lazy on demand in a thread. It is mainly with cookielib, but remember the...
41
by: z | last post by:
I use Visual C 2005 to develop my programs. One in particular is crashing in very specific and hard to replicate situations, made worse by the fact it only crashes when run -outside- the dev - as...
0
by: wolfonenet | last post by:
Hi All, My setup is: WinXP Python 2.5.1 TKinter version: $Revision: 50704 $ Tcl: 8.4 Debugger: WinPdb
5
by: Stef Mientki | last post by:
hello, The import statement "import sqlite3" gives the error given below. In simple programs, the import statement (sometimes) succeed, and I can indeed access the database. So I guess there is...
5
by: lixinyi.23 | last post by:
my code: main.cpp #include <Python.h> int main(int argc, char **argv) { Py_Initialize(); FILE *file_1 = fopen("a2l_reader.py","r+"); PyRun_SimpleFile(file_1,"a2l_reader.py");
0
by: John [H2O] | last post by:
There's a lot of greek for me here ... should I post to numpy-discussions as well??? The backtrace is at the bottom.... Thanks! GNU gdb Fedora (6.8-21.fc9) Copyright (C) 2008 Free...
3
by: ckkart | last post by:
Hi, on XP when starting a certain external program (plain C calculation program which communicates via stdout/fs) from python 2.5 using subprocess.Popen the external program crashes. It does not...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
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
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,...
0
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...

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.