Skip to main content

Memory comsumption and garbage collector

3 replies [Last post]
kawaiimomo
Offline
Joined: 2008-07-10
Points: 0

Hi all again,

I created a class extending Form. It sets a BorderLayout with:
- Container with BoxLayout(X) on NORTH [two Labels inside this container]
- TabbedPane on CENTER [a tab with a TextArea, the other with a Label]
I also add a Command, pretty simple.

I was monitoring memory usage on WTK2.5.2 and observed something strange to my understanding: By just moving the focus from a tab to another and viceversa the memory used grows extremely fast. I looked at the profiler and see that LWUIT doesn't seem to be making any calls to System.gc().

I attached a picture with the memory monitor and the emulator screen. Notice that memory arrived till almost 2 mb before garbage entered on stage. And I was just moving from a tab to the other. If I call the garbage collector trough memory monitor, all unused memory is released. That means this memory was allocated for nothing? Just for repainting and because no System.gc() calls were made??

If you look at the graphic in memory monitor, the highest peak is accomplished by only moving between tabs. Any info on LWUIT garbage collection? Does it relay on automatic calls? Should we make use of direct calls to System.gc()?

http://www.4shared.com/file/55668224/e150ef11/memory.html?

Thanks.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Francis De Brabandere

The VM won't free memory unless it needs to, this is no bug, it's
better to leave the garbage collection to the vm and never call
System.gc() yourself. I never use it and have no memory problems so
far.

Shai wrote a good blog post on this:
http://lwuit.blogspot.com/2008/06/memory-leaks-in-lwuit-and-tracking.html

On Fri, Jul 18, 2008 at 3:15 PM, wrote:
> Hi all again,
>
> I created a class extending Form. It sets a BorderLayout with:
> - Container with BoxLayout(X) on NORTH [two Labels inside this container]
> - TabbedPane on CENTER [a tab with a TextArea, the other with a Label]
> I also add a Command, pretty simple.
>
> I was monitoring memory usage on WTK2.5.2 and observed something strange to my understanding: By just moving the focus from a tab to another and viceversa the memory used grows extremely fast. I looked at the profiler and see that LWUIT doesn't seem to be making any calls to System.gc().
>
> I attached a picture with the memory monitor and the emulator screen. Notice that memory arrived till almost 2 mb before garbage entered on stage. And I was just moving from a tab to the other. If I call the garbage collector trough memory monitor, all unused memory is released. That means this memory was allocated for nothing? Just for repainting and because no System.gc() calls were made??
>
> If you look at the graphic in memory monitor, the highest peak is accomplished by only moving between tabs. Any info on LWUIT garbage collection? Does it relay on automatic calls? Should we make use of direct calls to System.gc()?
>
> [url]http://www.4shared.com/file/55668224/e150ef11/memory.html?[/url]
>
> Thanks.
> [Message sent by forum member 'kawaiimomo' (kawaiimomo)]
>
> http://forums.java.net/jive/thread.jspa?messageID=287553
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>
>

--
http://www.somatik.be
Microsoft gives you windows, Linux gives you the whole house.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
For additional commands, e-mail: users-help@lwuit.dev.java.net

kawaiimomo
Offline
Joined: 2008-07-10
Points: 0

Hi Francis,

I don't call this a bug, I'm just curious.

I made several MIDlets and never see a memory comsumption like this one. Although WTK memory monitor is pretty simple and liar, it serves me to take an overall look at things. And normally, gc enters everytime memory is rising over the highest peak, so it marks a new peak limit and calls gc. But this is not the case.

Anyway, Shai's post is worth reading :-) I crashed my head several years trying to monitorize memory/object usage under j2me. And agree, the s40 emulator is the most similar to reality.

Thanks, Regards.

Shai Almog

Hi,
there are several animations involved in traversal and other visual
effects (such as translucent background painters) that might not be
as immediately apparent when looking at the amount of garbage
created. Our policy has always been to create and dump so we can run
on a small device, the alternative is to cache information which
would cause a big problem in the long run.

Thanks,
Shai.

> Hi Francis,
>
> I don't call this a bug, I'm just curious.
>
> I made several MIDlets and never see a memory comsumption like this
> one. Although WTK memory monitor is pretty simple and liar, it
> serves me to take an overall look at things. And normally, gc
> enters everytime memory is rising over the highest peak, so it
> marks a new peak limit and calls gc. But this is not the case.
>
> Anyway, Shai's post is worth reading :-) I crashed my head several
> years trying to monitorize memory/object usage under j2me. And
> agree, the s40 emulator is the most similar to reality.
>
> Thanks, Regards.
> [Message sent by forum member 'kawaiimomo' (kawaiimomo)]
>
> http://forums.java.net/jive/thread.jspa?messageID=287568
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>

Shai Almog
http://lwuit.blogspot.com/

[att1.html]