 | 
July 9th, 2007, 10:54 PM
| | Member | | Join Date: Jul 2007
Posts: 38
| | 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. - for idx, wc in enumerate(c):
-
if wc == "&": #finds out if it the beginning of a '<'
-
activi=0
-
if wc == "l" and activi==0:
-
activi=2
-
if wc=="*" and activi==2: #previously marked each image with a '*'
-
url=c.replace('"', '').replace('*','')
-
jpg=url.find('jpg')
-
png=url.find('png')
-
gif=url.find('gif')
-
exten='mesa'
-
if jpg>=0: #only support jpg and png
-
exten='jpg'
-
name=url[jpg-15:jpg-2]
-
if png>=0:
-
exten='png'
-
name=url[png-10:png-2]
-
if gif>=0:
-
exten='gif'
-
name='mesa'
-
if exten != 'gif' and exten != 'mesa': #blit the image to the screen
-
name=name.replace("/", '')
-
temp=psp2d.Image('temp/%s' % name + '.' + exten)
-
locx=(480-(temp.width))/2
-
dy2+=16
-
bg.blit(temp, 0, 0, temp.width, temp.height, locx, dy2+dy)
-
dy2 += temp.height
-
temp=None #clear out the variables (thought this could help)
-
name=None
-
url=None
-
exten=None
-
png=None
-
jpg=None
-
gif=None
if I do this: - for idx, wc in enumerate(c):
-
if wc == "&": #finds out if it the beginning of a '< in the xml page'
-
activi=0
-
if wc == "l" and activi==0:
-
activi=2
-
if wc=="*" and activi==2: #previously marked each image with a '*'
-
url=c.replace('"', '').replace('*','')
-
jpg=url.find('jpg')
-
png=url.find('png')
-
gif=url.find('gif')
-
exten='mesa'
-
if jpg>=0: #only support jpg and png
-
exten='jpg'
-
name=url[jpg-15:jpg-2]
-
if png>=0:
-
exten='png'
-
name=url[png-10:png-2]
-
if gif>=0:
-
exten='gif'
-
name='mesa'
-
#if exten != 'gif' and exten != 'mesa': #blit the image to the screen
-
# name=name.replace("/", '')
-
#temp=psp2d.Image('temp/%s' % name + '.' + exten)
-
#locx=(480-(temp.width))/2
-
#dy2+=16
-
#bg.blit(temp, 0, 0, temp.width, temp.height, locx, dy2+dy)
-
#dy2 += temp.height
-
#temp=None #clear out the variables (thought this could help)
-
#name=None
-
#url=None
-
#exten=None
-
#png=None
-
#jpg=None
-
#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?
| 
July 10th, 2007, 12:57 AM
|  | Site Moderator | | Join Date: Sep 2006 Location: Minden, Nevada, USA Age: 45
Posts: 6,399
| |
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).
| 
July 10th, 2007, 01:56 AM
| | Member | | Join Date: Jul 2007
Posts: 38
| | Quote: |
Originally Posted by bartonc 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 - temp = psp2d.Image('temp/%s' % name + '.' + exten)
with - 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.
| 
July 12th, 2007, 06:00 AM
| | Member | | Join Date: Jul 2007
Posts: 38
| |
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: - lalala=psp2d.Image('static.png')
before this: - temp=psp2d.Image('temp/%s' % name + '.' + exten)
to make this: - lalala=psp2d.Image('static.png')
-
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.
|  |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | | | | What is Bytes?
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over network members.
|