• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Most heavy guy in j2me

 
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Jason Marlyn
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Ranch Hand
Posts: 40
Netbeans IDE Ubuntu Google App Engine
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Skool. Stay in. Smartness. Tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic