×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Regular Contributor
    Join Date
    Oct 2005
    Location
    Cairo,Egypt
    Posts
    72

    Red face Code Optmization Question

    I have some issues confuse me about how to write optmized code for j2me devices with it is limited memory and speed.
    so i will start with
    1- Create one static instance from specific class and use it every time i need or make a new instance every time i need it. Which are the Best?
    like

    "MyMidlet.display.setCurrent(MyMidlet.ModifiedListStaticInstance)"
    "MyMidlet.display.setCurrent(new ModifiedList())"

    make in your mind that iam using this ModifiedList many times in my application.

    After That i will contain My Questions Thanks
    Thanks for share your Experience.

  2. #2
    Registered User
    Join Date
    Dec 2005
    Location
    Brazil
    Posts
    1,884

    Re: Code Optmization Question

    Hi Spider_Eg,

    Well, in Java static variables are "class variables", they do belong to class and not to a particular instance. Non-static (instance) variables are the opposite, obviously.

    If your state can be shared by several instances with no side-effect then it's fine.

    A regular, generational JVM has several heap spaces (young gen, old gen, survivor spaces and permanent area). Static variables will be in the permanent area and they will be released when the class is unloaded by the classloader or GC in case you nulls it.

    I'm not sure what's the case for KVM and even for CLDC HI VM (the paper from Sun only shows young and old generations). Maybe someone could provide more info about that.

    Take a look at the paper below if you want to know more about CLDC HI:

    CLDC HotSpot Implementation Virtual Machine White Paper
    http://java.sun.com/j2me/docs/pdf/CL...ruary_2005.pdf

    Also, JME performance tunning tips:
    http://www.javaperformancetuning.com/tips/j2me.shtml

    BR

  3. #3
    Regular Contributor
    Join Date
    Oct 2005
    Location
    Cairo,Egypt
    Posts
    72

    Re: Code Optmization Question

    Thanks juarezjunior for Reply
    iam now reading CLDC paper ......
    and it will be usefull if some one answer us on practical way......
    and i have a question about making the static variables with null.
    2- Is the GC will work autmatically or I must Force it to work by System.gc();
    and after 6 monthes in J2ME iam starting not sure about this GC work
    Especially some times i need to renew this static instance and i make this first with null and GC if this object is big enough for that then recreate it.
    and iam now try to make refresh() function to make my changes without recreate because of time waiting

    Thanks For Your Time

Similar Threads

  1. Replies: 2
    Last Post: 2003-11-09, 14:00
  2. Formatting code in posts to these boards
    By GerardMason in forum Mobile Java General
    Replies: 1
    Last Post: 2003-09-30, 18:28
  3. Replies: 0
    Last Post: 2003-09-26, 15:07
  4. Testing HTTP client for Nokia 3650; Looking to share code
    By nawkboy in forum Symbian Networking & Messaging (Closed)
    Replies: 2
    Last Post: 2003-09-10, 15:30
  5. problem with Nokia Toolkit 3.1 and binary code for MMS
    By alinesimon in forum General Messaging
    Replies: 1
    Last Post: 2002-08-09, 06:40

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×