memory leak

My app has a memory leak. I'm a noobie and I've been struggling to figure out how to plug it.

The following code is what is highlighted when I get the out of memory error:

instText.clear(); 
instText.add(loadImage(dataPath(textName)));

It's contained in a conditional and loads a different image every time I press a button. I tried to change it to.

instText.clear(); 
System.gc();
instText.add(loadImage(dataPath(textName)));

But I still got a memory error. Any advice would be appreciated.

Tagged:

Answers

  • Please post a MCVE that demonstrates the problem. Note that this should not be your full program! It should be a small example that shows the same behavior.

    Also note that calling System.gc() isn't going to do anything to avoid an OutOfMemoryError.

  • What is instText? Can you post an MCVE demonstrating your problem?

    Kf

Sign In or Register to comment.