Error Handling: outofmem issue

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
Karasuro
Prole
Posts: 19
Joined: Wed Aug 21, 2013 5:32 am

Error Handling: outofmem issue

Post by Karasuro »

Environment
Version: Love 11.3
Platform: Raspberry Pi 4 Model B+ (8GB Ram)
System: 32-bit
Kernel version: 6.1
Debian version: 12 (bookworm)

External Requirements
libgphoto2 (external camera control)
lua-periphery (GPIO control)
nativefs (accessing external directories) [included in the archive]

Program Function
Loop a short video while in Idle State.
Receive a signal from a NA-M7RF laser to trigger the capture of an external camera.
Save the JPEG to disk, overwriting any previous JPEGs taken.
Load the new JPEG into the program.
Display the JPEG for 20 seconds.
Return the Idle State.

Error
lib/assetloader.lua 38: Could not decode image with stb_image (outofmem)
That line of code is just: self.cameraImage = love.graphics.newImage("MyFilePath")

assetloader.cameraImage is only used in Draw() by graphics.draw() while in the CameraWait state (See Notes Below)

Notes
Update() and Draw() are written as a basic State Machine.
The program has 4 states: IdleImage, IdleVideo, CameraCapture, and CameraWait
The program should Idle on either IdleImage or IdleVideo (IdleImage is only set if the program can not load the video.)
When the Idle states get a signal from the Laser, it swaps over to CameraCapture where it checks to see if the External Camera saved the image to disk.
If it did not, then it just goes back to Idle. Otherwise it will swap to CameraWait for 20 seconds displaying the new image taken, then it goes back to Idle.
Attachments
camsys.love
Does NOT run without the correct Environment.
(8.82 KiB) Downloaded 53 times
User avatar
pgimeno
Party member
Posts: 3550
Joined: Sun Oct 18, 2015 2:58 pm

Re: Error Handling: outofmem issue

Post by pgimeno »

My first suspicion would be the saved JPEG file, Have you checked if the JPEG loads fine in isolation?
User avatar
Karasuro
Prole
Posts: 19
Joined: Wed Aug 21, 2013 5:32 am

Re: Error Handling: outofmem issue

Post by Karasuro »

Yes. This only occurs after hours of continuous operation which makes me think memory isn't properly getting cleared somewhere.. I just can't pinpoint it.
User avatar
pgimeno
Party member
Posts: 3550
Joined: Sun Oct 18, 2015 2:58 pm

Re: Error Handling: outofmem issue

Post by pgimeno »

Oh you didn't mention that before did you?

Maybe the issue is that you're not releasing the previous image (Object:release) and there are too many in RAM or VRAM waiting to be garbage-collected?
User avatar
Karasuro
Prole
Posts: 19
Joined: Wed Aug 21, 2013 5:32 am

Re: Error Handling: outofmem issue

Post by Karasuro »

So in assetloader.lua I should just call self.cameraImage:release() before assigning it as a graphics.newImage()? Assuming it's not the first call and self.cameraImage is nil..
User avatar
pgimeno
Party member
Posts: 3550
Joined: Sun Oct 18, 2015 2:58 pm

Re: Error Handling: outofmem issue

Post by pgimeno »

That's right. See if that solves anything.
User avatar
slime
Solid Snayke
Posts: 3133
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Error Handling: outofmem issue

Post by slime »

You may also want to add some validation/logging to your code to make sure the newImage call is happening as infrequently as you expect.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 54 guests