Connecting Tech Pros Worldwide Help | Site Map

PSP crashes when my python program

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 9th, 2007, 09:54 PM
Member
 
Join Date: Jul 2007
Posts: 38
Default 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?
Reply
  #2  
Old July 9th, 2007, 11:57 PM
bartonc's Avatar
Moderator
 
Join Date: Sep 2006
Location: Minden, Nevada, USA
Age: 46
Posts: 6,400
Default

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).
Reply
  #3  
Old July 10th, 2007, 12:56 AM
Member
 
Join Date: Jul 2007
Posts: 38
Default

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
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.
Reply
  #4  
Old July 12th, 2007, 05:00 AM
Member
 
Join Date: Jul 2007
Posts: 38
Default

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.
Reply
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search


Popular Articles

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 220,989 network members.