Memory leaks on WebOS?

Previous topic - Next topic

ampos

How can I check for memory leaks on WebOS?

My (problematic) app load jpeg files with LOADSPRITEMEM, resizes to something usable (2048x2048) on another array and MEM2SPRITE. ALl the arrays are local, so they are "freed" after each call... around one each 6 seconds.

Can this scenary run into a memory leak, or memory fragmented issue?

One user has said me that if it has Kindle open, my app just closes (so or Kindle or DPF are eating a lot of memory, or both).

The app has always 3 2048x2048 images on memory, a font bitmap and just a few little sprites for buttons.

Here is my jpg loading routine with resize

Code (glbasic) Select
FUNCTION loadjpg: f$,id
LOCAL w%,h%,ok,pix%[],tpix%[]
LOCAL size=maxsize  //2048 for TP

ok=LOADSPRITEMEM(f$,w%,h%,pix%[])

IF w>size OR h>size
LOCAL sx=INTEGER(w/size)
LOCAL sy=INTEGER(h/size)
LOCAL s=(MAX(sx,sy))
sx=INTEGER(w/s);sy=INTEGER(h/s)
DIM tpix%[(sx*sy)]
ok=0
FOR y=0 TO sy-1
FOR x=0 TO sx-1
tpix[ok]=pix[(x*s)+((y*s)*w)]
INC ok
NEXT
NEXT
MEM2SPRITE(tpix%[],id,sx,sy)
ELSE
MEM2SPRITE(pix[],id,w,h)
ENDIF
ENDFUNCTION


The app is running at my house 24 hrs per day, with 1024x768 pixel photos. When I come from work, 75% of the times the app has crashed with a "unknown error" on WebOS.

I did place log-points on the app, and the crash was never inside the loading routine but in the displaying one. Strange.

Any hint?

Is there a way to reserve a fixed amount of memory for jpg loadings?

spacefractal

You can't use STATIC for pix and tpix variables?

and yes mem2sprite might not correctly have released its memory and might leek? its can been correct here? but absolut net tested the code.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/