This site requires JavaScript, please enable it in your browser!
Greenfoot back
CeeCeeLemons
CeeCeeLemons wrote ...

2018/2/15

GifImage Heap Space Error

CeeCeeLemons CeeCeeLemons

2018/2/15

#
I have been working on playing a video in Greenfoot by playing a gif and mp3 file, and have been using information from this thread to display my gif. Older Topic The problem is that I run into a java heap space error when I try to play the gif. "java.lang.OutOfMemoryError: Java heap space" I'm fairly new to java and coding and I am trying to see if I can fix this. By going into the GifImage class and decreasing numFrames to 30, I don't get an error and can play the first 30 frames of my gif. Any thoughts?
Vercility Vercility

2018/2/15

#
Error is basically just telling you that the environment went out of memory because you're saving too much stuff. Try a shorter gif or decrease the world's size (effectively cutting the image size as well), maybe u're running an infinite loop too but i doubt that when it works with 30frames/s
Super_Hippo Super_Hippo

2018/2/16

#
You can also increase the java heap space. In any way, you could show the code so we can see if there are any mistakes.
CeeCeeLemons CeeCeeLemons

2018/2/17

#
Here is some of my code in my Video class:
    public Video(int n)
    {
        gifName = "videos/Gif_" + n + ".gif";
        gifImage = new GifImage(gifName);
        adNumber = n;
        adSound = new GreenfootSound("Ad_" + n + ".wav");
    }
And in act():
setImage(gifImage.getCurrentImage());
The gif is 15 seconds long, as I am trying to simulate a video. I might just try cutting out every 10 frames and playing the gif at 1/10 of the speed. Thanks for your quick responses!
You need to login to post a reply.