Possible memory leak in gloss

68 views
Skip to first unread message

laith alissa

unread,
Nov 20, 2012, 7:36:27 PM11/20/12
to haskel...@googlegroups.com
Hi there,
I'm having a memory issue with gloss and I was directed to report it to the developers. I recently posted a question to SO:

http://stackoverflow.com/questions/13479126/how-do-i-stop-gloss-requiring-an-increasing-amount-of-memory#comment18448179_13479126

Somebody ran a profile which showed the memory leak was within gloss. If somebody picks this up could they keep me informed, I'm using gloss for my degree project and if I have to drop it I need to do so as soon as possible.

Thanks
Laith Alissa

Thomas DuBuisson

unread,
Nov 20, 2012, 7:59:24 PM11/20/12
to haskel...@googlegroups.com
I saw your question and have only taken enough time to verify that I
can reproduce it on my machine. On my machine, the resulting program
grow in heap more slowly, perhaps 0.025 MB every 5 seconds, but it did
grow. I (who am not the developer) will take a closer look as time
allows.

With respect to your needs, would your use of gloss actually be so
long running that this memory use would become a problem? If not,
then there is no hurry. If so then I am intrigued (not that you need
to explain anything).

Cheers,
Thomas
> --
>
>

laith alissa

unread,
Nov 21, 2012, 11:17:50 AM11/21/12
to haskel...@googlegroups.com
My project team are developing a Haskell RTS game (similar to Red Alert 2) for our university degree. Of course the memory leak in the example isn't particularly concerning, but I have to be sure that the bug won't become more severe when gloss is managing an environment with a large number of entities. I'll be doing some testing to make sure it won't be a problem, but I thought it bese to ask around the Haskell community to see if somebody knows what's happening. Thanks for your reply.

Jon Cave

unread,
Nov 21, 2012, 12:27:35 PM11/21/12
to haskel...@googlegroups.com
On Wednesday, 21 November 2012 00:36:27 UTC, laith alissa wrote:
I'm having a memory issue with gloss and I was directed to report it to the developers. I recently posted a question to SO:

http://stackoverflow.com/questions/13479126/how-do-i-stop-gloss-requiring-an-increasing-amount-of-memory#comment18448179_13479126

Somebody ran a profile which showed the memory leak was within gloss.

Looking at the graph linked in the SO comment I noticed that State is taking up a lot of memory. In Graphics.Gloss.Internals.Interface.Animate.Timing, the State IORef is read a number of times via getsIORef. I switched from multiple getsIORef calls to one readIORef and then using the functions on the returned value, i.e.

    state <- readIORef stateRef
    let displayTimeLast = stateDisplayTime state

    -- ...

    let animate = stateAnimate state

    -- ...

This change approximately halved memory usage over a 60 second test run.

Unfortunately there is still a steady increase in memory. It looks like there's something else causing problems in Graphics.Gloss.Internals.Interface.Animate.Timing, see the second and third items in the graph posted by hammar on SO.

Jon

Christiaan Baaij

unread,
Nov 21, 2012, 3:15:53 AM11/21/12
to haskel...@googlegroups.com
Hi,

Which version of gloss are you using? And on what platform (OS & GHC version)?
Also, are you using the GLUT or the GLFW backend?
Does the heap-size also increase if you're displaying something other than text?
Say, a rotating square?

Cheers,

Christiaan
> --
>
>

Ben Lippmeier

unread,
Nov 26, 2012, 12:29:27 AM11/26/12
to haskel...@googlegroups.com, laith alissa

On 22/11/2012, at 3:17 AM, laith alissa wrote:

> My project team are developing a Haskell RTS game (similar to Red Alert 2) for our university degree. Of course the memory leak in the example isn't particularly concerning, but I have to be sure that the bug won't become more severe when gloss is managing an environment with a large number of entities. I'll be doing some testing to make sure it won't be a problem, but I thought it bese to ask around the Haskell community to see if somebody knows what's happening.


Thanks, I fixed this in gloss-1.7.7.1. It was a typical laziness-induced space leak in the code that manages the frame timing for animations.

The program on SO now runs in constant space.

Ben.

Reply all
Reply to author
Forward
0 new messages