Memory Consumption

  • YanXu

    YanXu - 2010-09-27


    I WAS using Microlog on an embedded Java Platform. But recently I got into some trouble regarding the memory usage. This device im using is CLDC 1.1/ IM profile which means no display etc. Thankfully, Johan (i think?) split up the jar file so I could use it without having a display. Then I was using only the core lib which worked perfectly at the beginning of implementation. But because of the fact, that my project was a very complex one plus my device had only 400k of RAM available, I exceeded the limits and got OutOfMemoryException here and there. Unfortunately, I had to remove Microlog from my project because after investigating the memory sinks, I found out that microlog already consumed approx. 100k and was the #1 consumer in my system. I had to replace it by an own implementation that supports appenders and a hard-coded formatter. 100k includes heap usage as well as byte code which will be loaded into memory by the JIT compiler.

    I know, that on systems like Android, where you have like 512MB RAM, 100k definitely not the issue. But on low-end industrial applications, it is. If your focus is more on high-end mobile device, it's fine.

    For me, maximum obfuscation shrinked my jar file from >400k to 150k. I analyzed the class files, and mostly, it's filled with full-qualified Java package names.

    I just want to let you know this.


  • Johan Karlsson

    Johan Karlsson - 2010-10-09

    Hi Jan,

    sorry that Microlog did not work the way that you wanted it. I am a little bit surprised that you ran into memory problems. I have tested Microlog on mobile devices with devices with less memory than you are talking about.

    But we must see the difference between the run-time memory and the jar sizes. I have split up the one big jar into several jars, for people to handpick the parts that they like. But the division is far from optimal. In a memory constrained system like yours I recommend to import Microlog as source code. The you could easily customize a Microlog that takes less than 100kb.

    Did you use the PatternFormatter? It has several helper classes and uses more memory than the SimpleFormatter. So you should use SimpleFormatter, or make your own. Maybe modify the SimpleFormatter for you needs?

    I also recommend that you read this article:

    I hope that you switch back to Microlog, now that you know how to do it.

    Best Regards


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks