(LibGDX | SOLVED) Memory Leak/Issue With ShaderProgram

Hi, I’ve noticed a dip in performance as time goes on in my game and decided to boot up JConsole and MAT (eclipse memory analyzer). To my surprise and from what I can see (I’m not very informed when it comes to memory), none of my classes seemed to be the suspect in leaking memory; the culprit was LibGDX’s ShaderProgram.

I’m not sure if I’m suppose to interact with the class, but so far in my code I have not referenced it. I did a quick google search if there have been any problems with it- nothing showed up. I went deeper and checked out what references ShaderProgram to see if I’m referencing it indirectly, and I found that SpriteBatches have a method to create a default ShaderProgram. But I don’t call it.

Here’s what MAT spit out for its suspect:

Here’s the dominator tree:

I still have the heap up in MAT if you have further inquiries.

TL;DR LibGDX’s ShaderProgram class is leaking memory (one time it got up to 1.5GB)

I’m not familiar with that program, but are you sure you’re interpreting this correctly? Isn’t it saying that there are a crapload of ShaderProgram objects, and they’re all stored in a single Object[]? Wouldn’t that simply mean that you may be loading shaders, throwing them on an ArrayList somewhere and forgetting about them, preventing them from being garbage collected?

Oh yeah I was. What I meant was that I never used ShaderPrograms or stored them anywhere. I actually don’t even have any Object arrays.

Anyway, I resolved the issue by mistake. After dividing my rendering tasks into more evenly grouped SpriteBatches the memory leak disappeared. Sorry for a very vague solution, but that’s what I did.