I'm getting OutOfMemoryError in a j2me application.
How can I find what is causing this error? And how to prevent getting this error?
EDIT: I make a http request. While the request isn't completed the screen shows a loading image (like a browser shows when a page is loading). This was done by creating an Image and repainting the screen.
create image 1 -> repaint -> create image 2-> repaint-> create image 3 -> repaint -> create image 1-> repaint -> ....
I noticed (using wtk memory monitor) that this was consuming too much memory that wasn't garbage collected.
Then I tried to create a class that is kind of pool of images. This class creates all the images and then show them.
create image 1 -> create image 2-> create image 3 -> repaint -> repaint -> repaint -> repaint -> repaint -> ...
This second scenario doesn't seem to consume as much as memory than the first one. (using wtk memory monitor).
However, I think (not sure if is this) those both approaches are contributing to cause this OutOfMemoryError.