• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Most heavy guy in j2me

 
Zaeed McColin
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys, I'm weak in j2me and I've tried to create my first application and I've faced with a issue, it's not really a issue it's more like a question, anyway, I'd would to know, what is the most heavy class(interface implemented) in j2me classes? such a Ticker or Alert, I don't know. so please help me out with this issue. thanks
 
Alex Parvan
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by the most heavy ? The most used class ? If you use high level GUI, i think it's Form, if you use low level GUI then Canvas. Or actually, i think CommandListener is the most used class.

Post any questions here, i will answer them if i can.
 
Zaeed McColin
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Alex. I mean which object (component) is used most memory usage?
 
Alex Parvan
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It might not seem clear, but actually String is using up the most memory.

For example, creating Strings like this:

is very bad practice. When using very long Strings, you might encounter problems.
Strings should be created like this:

You don't really have to worry about memory so much. Using large Images or doing complex operations (like constructing an Image from pixel data) is the only thing you should be carefull with.

You can always read how much memory you have by using:


Hope this helps !
Alex
 
Lorand Komaromi
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alex Parvan wrote:
For example, creating Strings like this:

is very bad practice.


Compile it, then decompile it with jad. You will be surprised...
 
Alex Parvan
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lorand Komaromi wrote:Compile it, then decompile it with jad. You will be surprised...

I know it as a fact (search StringBuffer). Strings are immutable, every time you use one, memory is allocated, while StringBuffer can change it's value, therefore you avoid creating multiple temporary Strings.
 
Lorand Komaromi
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Java SE the compiler will optimize the string concatenation to use StringBuilder. In ME this could be different, though...
 
Srinath Gamage
Ranch Hand
Posts: 40
Google App Engine Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From my experience on J2ME Game development, getGraphics(); is the most heaviest thing.
 
Alex Parvan
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Srinath Gamage wrote:From my experience on J2ME Game development, getGraphics(); is the most heaviest thing.

Well yes, but you never expect some concatenations to give you an OutOfMemoryException It's true they have to be really long.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic