Discussion Board

Results 1 to 9 of 9
  1. #1
    Regular Contributor mikecotic's Avatar
    Join Date
    Oct 2008
    Posts
    56
    will the GC collect my form after it switched to some else display on the main midlet , if use the following code :

    (new myForm()).show(Form2);

    the show method takes for an argument a form to set as the next displayable after the user performs some actions on the myForm instance.

    Form2 is declared on the main midlet.

  2. #2
    Nokia Developer Champion raj_J2ME's Avatar
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,314
    Hi,
    I am sure that I am not clear about exactly what you are looking for.
    Please provide more information...
    Thanks,
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  3. #3
    Regular Contributor mikecotic's Avatar
    Join Date
    Oct 2008
    Posts
    56
    i am talking about the java garbage collector .
    once i use my following code, a form is displayed to the user [lets call that instance of MyForm , frm].
    then the user clicks back or something on that form[the frm form] and the displayable is changed . my question is will the garbage collector recycle that form [the frm form] i opened with the line of code.
    i am asking because who knows java maybe there is a pointer to that form left somewhere and it wont let it die.

  4. #4
    Nokia Developer Champion Tiger79's Avatar
    Join Date
    Apr 2007
    Posts
    2,697
    well to be sure it gets destroyed u can set it to null,
    as in Form1 = null;
    the GC will clear that up for you whenever the os thinks its time for it to run...

  5. #5
    Regular Contributor Pradeepcg's Avatar
    Join Date
    Feb 2006
    Posts
    65
    GC runs as a JVM initiated Thread and is in no way accessible to the Developer. i.e You have no control over GC .. To be sure that the GC collects your Form whenever it runs set it to null when its use is over.
    Thanks and Regrads
    Pradeepcg

  6. #6
    Regular Contributor sunil_bhambani123's Avatar
    Join Date
    Sep 2008
    Location
    Ahmedabad
    Posts
    254
    Hi,

    If you want to explicitly call Garbage Collector you can use System.gc() or Runtime.getRuntime().gc(). But this also wont guarantee that Garbage Collection will take place, atleast will inform GC that application needs Garbage collection to be done.
    Sunil
    Mobile Application Developer

  7. #7
    Nokia Developer Champion raj_J2ME's Avatar
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,314
    Hi,
    Note that -

    Java runtime system performs the garbage collection asynchronously depending on the available resources. When there are no more references to an object, the object is finalized and when the Garbage Collections starts these finalized objects gets collected.

    Sometimes you need to run garbage collector explicitly just before some memory intensive task. You can run garbage collector by this statement.

    System.gc();

    Finalization process can also be invoked explicitly using the following statement. After the execution of this statement all the objects those are without reference, are finalized.

    System.runFinalization();
    The best disscussion I have seen so far..go through
    http://chaoticjava.com/posts/how-doe...llection-work/
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  8. #8
    Regular Contributor mikecotic's Avatar
    Join Date
    Oct 2008
    Posts
    56
    to all those who told to do something = null; -> guys i don't reference this form in my code!
    and to the last guy thank you very much.

  9. #9
    Nokia Developer Champion Tiger79's Avatar
    Join Date
    Apr 2007
    Posts
    2,697
    sorry,
    thought u had an object just like in ur description of ur situation :
    the frm form

    which u dont need anymore, so u can actually set it to null (frm == null), which will be cleaned up next time the gc will be run by the os...
    but if u say u dont reference it, then I guess there is no way for urself to "hint" a gc to the os...

Similar Threads

  1. Advice For J2ME Application and Question
    By localarea in forum Mobile Java General
    Replies: 2
    Last Post: 2008-06-30, 01:36
  2. Question : Server (VC++ Widcomm SDK) --> Client (J2ME JSR82 API)
    By Arch_Cancer in forum Mobile Java Networking & Messaging & Security
    Replies: 0
    Last Post: 2008-05-27, 07:41
  3. J2ME L2CAP Quick Question =>>>
    By zinomorph in forum Bluetooth Technology
    Replies: 0
    Last Post: 2005-08-02, 15:08
  4. J2ME RFCOMM Quick Question =>>>
    By zinomorph in forum Bluetooth Technology
    Replies: 0
    Last Post: 2005-08-02, 14:49
  5. J2ME Polish 1.0 RC1!
    By enough in forum Mobile Java General
    Replies: 1
    Last Post: 2004-06-15, 02:53

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved