When does java deallocate memory for objects;

um i'm working on a midp application that is very memory consuming. i would like to optimise it and make it just the oposite of what it is. now i would like to know when does java dellocate memory for an object, is it when it can find no more references to that object? or some other time, well i know its not when it can find no more references to that object because i've already tried that.
or to make things simpler is there any explicit way to make java deallocate memory for a specific object, like if i have a thread, which is executing a while loop, and i want java to end the thread and free its memory. is there any way to do this?

I happen to have quite some J2ME experience and it's not overly wise to count on extensive garbage collection. The garbage collector in limited device VMs isnt as advanced as it's big brothers. Try to avoid excessive object allocation and reuse instances whenever possible.
As for garbage collection, objects will be garbage collected if they can no longer be reached by any of the active application threads and if the garbage collectors deems it necessary to collect garbage, which will probably be when free heap memory becomes sparse or when there's some idle time in your application.

Similar Messages

  • How does Java structure memory for an object's members?

    I'm trying to figure out how Java structures/allocates memory for objects. (Yes this is implementation specific. I'm using the Oracle 1.7 runtime for this.) I did some work on this here and here and the results are confusing.
    First off, in both referenced links, when I allocated an array of objects, the equivalent of new Object[10000], it used 4 bytes per object. On a 32-bit system this makes perfect sense. But I'm on a 64-bit system so what's going on here?
    Is Java limited to a 32-bit address space even on 64-bit systems?
    Is Java limited to a 32-bit address space per array and each array object then has a pointer to where the elements are?
    Something else?
    Second, I compared the memory footprint of 8 booleans vs. a byte as the variables in a class. The 8 booleans requires 24 bytes/object or 3 bytes/boolean. The single byte approach requires 10 bytes/object.
    What is going on with 3 bytes/boolean? I would understand 4 (making each an int) and definitely 1 (making each a byte. But 3?
    And what's with expanding a byte to 10 bytes? I would understand 8 where it's expanding a byte to a native int (I'm on a 64-bit system). But what's with the other 2 bytes?
    And in the case of different ways to create a RGB class it gets really weird.
    For a class composed of 3 byte variables it uses 24 bytes/instance. Expensive but understandable as each uses an int.
    So I tried where each class is a single int with the RGB stored in parts of the int (using bit shifting). And it's still 24 bytes/instance. Why on earth is Java taking 3 ints for storage? This makes no sense.
    But the weirdest case is where the class has a single variable of "byte[] color = new byte3;" Note that the byte is allocated so it's not just a null pointer. This approach takes less memory than the other two approaches. How???
    Any guidance as to what is going on here is appreciated. I have a couple of classes that get allocated a lot and the flywheel pattern won't work (these objects have their values changed all over the place).
    And an associated question, does the order of declaring variables matter? Back in the old days when I did C++ programming, declaring "int, byte, int, byte" used 4 int's work of space while "int, int, byte, byte" used 3.
    thanks - dave

    This is a quadruple crosspost.

  • When does converter program begin for me?

    I purchased the $19.99 annual package to convert .pdf to Word and Excel.  Did so on Friday, February 3.  How long before the program works for me?  Larry Walker, Pensacola, FL

    Newbie. Should have marked this to you.
    7. Feb 13, 2012 3:48 PM (in response to Larrywalker2007) 
    Re: When does converter program begin for me?
    I have same issue in Atlanta. Purchased Feb 13. Confirmed that same email is being used as when subscribed. (No luck, even when clicking on link in "Verify your email" from Adobe). It shows that I have a paid subscription in "My Subscriptions".
    Ted in Atlanta

  • When does java 7 come out?

    when does java 7 come out?

    masijade. wrote:
    aszxcv02 wrote:
    when does java 7 come out?I always thought it was straight!That's why it needs coming out, isn't it? ;-)

  • Which way is used to allocate/deallocate memory for locals?

    Good afternoon.
    I would like to know how memory is allocated/deallocated for local variables in an activation record/frame. For example, in the following java code:
    1 public void test()
    2 {
    3     {          
    4          {
    5               String y = "abc";
    6          }
    7     }
    8     {
    9          String y = "pqr";
    10     }
    11 } At line 5, memory is allocated for variable y. Is this memory deallocated at line 6 (right after its declaration block), or after the line 11 at which point the whole activation record for the method is popped out of the stack?
    In addition, is this local memory allocation/deallocation strategy required by the Java specification, or could be different with different Java compilers? Thank you very much and have a great weekend,
    Sunny

    Hi,
    Thank you for your comments!
    Perhaps I did not state my problems clearly. Here is my real purpose: I am trying to monitor a program's runtime behavior by dynamically maintaining an object graph where nodes represent runtime objects and directed edges represent "refer to" relation between objects. To better understand my questions, let me first briefly introduce my algorithm to update the object graph:
    1. add an edge (between objects): when a local refers to an object, add an edge from the enclosing object to the referred object
    2. delete an edge: when a local refers to another new object, delete the edge from the enclosing object to the previously referred object; or the memory allocated for this local is deallocated.
    For example, if I have the following Java method,
    1 m()
    2 {
    3        {
    4                 Object x = objA;
    4'                x = objB;
    5                 // some statements
    6        }
    7        {
    8                 // some statements
    8'                Object x = objC;
    9        }
    10 }Below, the enclosing obj means the object containing the method m().
    At line 4, a local name x is declared and assigned objA, at which point an edge from the enclosing obj to objA should be added. At line 4' the same local is assigned a new value, at which point we should delete the edge from the enclosing obj to objA and add a new edge to objB.
    At line 6 this local is out of its scope, whether or not we should delete the edge from the enclosing obj to objB depends on whether the memory allocated for x is deallocated.
    Lastly, at line 8' a new local with the same name x is declared so we should add a new edge...
    Another example is like this:
    1 m1()
    2 {
    3      Object x = objA;
    4     // some statements
    5     m2();
    6 }
    7 m2()
    8 {
    9     Object x = objB;
    10     // some statements
    11 }After line 9, I should be able to know the enclosing obj has two outgoing edges labeled with x, one is to objA and the other is to objB.
    Is there any solution to getting this runtime information for Java local variables? I would really appreciate any help!
    -- Sunny

  • Best practice power setting when doing a Site Survey for VOIP

    Hi Team,
    Can someone please confirm or correct me.  When doing a Wireless Active Site Survey for Cisco VOIP, I should be setting the Test AP to local power of 14, which is 25mW?  Is this correct, or should it be another value?  I asked the customer for the power of their weakest client and they do not know, but they claim there's a high probably that they will go with Cisco VOIP clients.
    Thanks...

    When you check the signal coverage, make sure the AP's radio transmit power does not use a transmit power greater than what the client devices can support. For example, by default, the Cisco Unified Wireless IP Phone 7925G uses the highest available transmit power by default (17 dBm / 50 mW for 2.4 GHz and 16 dBm / 40 mW for 5 GHz). It is possible to have a survey report that shows good coverage in all areas; however, if you have APs that operate at the highest transmit power, you might still experience uplink issues where the client devices do not support the same transmit power. For areas where there is deficient coverage, and you increase the AP transmit power to levels that the client devices cannot support, this only increases coverage on the downlink.
    Link for the same :-
    http://www.cisco.com/c/en/us/support/docs/wireless/5500-series-wireless-controllers/116057-site-survey-guidelines-wlan-00.html

  • When does ios7 come out for ipod 4

    When does it release for ipod 4s

    There is no iPod 4s, just an iPod 4. There will not be any iOS 7 upgrade for the iPod 4G Touch.

  • Does Java have APIs for statistical analysis?

    Hi Java Experts
    I want to develop a Java program which can help users to analyse their stock investment. Here I have two questions
    1) How can I wrap my finished Java program as a XXX.exe? So users can install my program by executing it
    2) Does Java have any APIs for statistical analysis?
    Thank you very much for your help!
    ViolaIT

    1) How can I wrap my finished Java program as a
    XXX.exe? So users can install my program by
    executing ithttp://onesearch.sun.com/search/onesearch/index.jsp?qt=java+exe&qp_name=null&subCat=siteforumid%3Ajava54&site=dev&dftab=siteforumid%3Ajava54&chooseCat=javaall&col=developer-forums

  • Does Apple sell memory for Apple iMac 3.06GHz Intel Core 2 Duo (21.5-inch - DDR3) Late 2009 anymore?

    I have a 21.5-inch, late 2009 iMac (Apple iMac 3.06GHz Intel Core 2 Duo [21.5-inch - DDR3]) and I need more memory for it. Currently, I have the standard 4GB memory for it (2X2). I wanted to know if Apple makes memory for my model iMac anymore. Thanks!

    Buy your ram from either Crucial http://www.crucial.com or OWC http://eshop.macsales.com.
    Apple probably still sells ram for your iMac but you'll pay twice the prince and get less for it.

  • When does ios7 come out for iPad?

    I would like to enquire about when iOS 7 comes out for the iPad?

    When a date is announced it will probably be shown at the top of this page : http://www.apple.com/ios/ios7/features/ (at the moment it just says 'coming this fall')

  • When does Java load classes?

    Hi there,
    I have a question about when Java is loading class? Does it load the class when use it or it will load all classes in the scope in one shot?
    Let's say I have a projectA java program which has classA:
    class classA{
    I have a jar file: my.jar which uses classA if it is used in projectA:
    class myClass{
    if( enviroment.equals("projectA") )
    classA a = new classA();
    This works no problem.
    Now let's say I have another program call projectB, which does NOT has classA; Now, can I link my.jar to this projectB and run??
    Thanks

    Java loads classes only upon access.

  • When does TM erase backups for removed USB/FW drives?

    I have a MacBook Pro running 10.6.1 and I have a 2TB Western Digital My Book Studio (formatted HFS and attached with FW800) on which I store a lot of data (about 1.2 TB).
    I have a couple of backup strategies including Time Machine (my Synology NAS acts as Time Machine server) and I would like to understand better what happens if I allow TM backups to occur WITHOUT my WD My Book FW800.
    My concern is - would TM automatically 'remove' the backups of my FW drive if it's not connected when a backup occurs? This might occur once every four backups...

    rafsanchez wrote:
    Pondini wrote:
    That's not what it says, and not what it means. That article is about when to use Time Machine vs. the Backup application (part of a Mobile Me subscription).
    Whilst the KB does mainly deal with when TM should be used and when Backup should be used, I'm not sure what you mean by "that's not what it says"? The KB does clearly state (as I quoted in my post) that "Time Machine allow you to back up data to a network volume". Perhaps Apple needs to change the text of this KB and make it clear that the "network volume" they mean is only the Time Capsule or later AirDisk.
    Perhaps you need to tell Apple that: http://www.apple.com/feedback/
    TM will do network backups, but only to a Time Capsule; or a shared disk on another Mac running Leopard or Snow Leopard on the same local network; or a USB drive attached to a (recent) Airport Extreme.
    Actually this is not correct as I have been successfully using both Synology and a ReadyNAS devices as TM volumes...all that is needed is a network volume that supports sparsebundle disk images (no firmware hacks on either the NAS or the Mac are needed).
    Yes, sometimes it will. Excuse me for not prefacing that with the word "Officially."
    There are a number of threads here and in the +Leopard / Time Machine+ forums where it works for a while, then something goes wrong, and there don't seem to be any solutions.
    There's even a chance that your backups will be useless just when you need them the most.
    I'm not worried about this because, as I mentioned in my original post, I have a couple of backup strategies
    As long as you (and others who might read this) understand the risks.

  • Does Java have a chart object?

    Hi:
    Thank you for read my message.
    Do you know if Java has an object to create chart or to plot information?
    If your answer is yes, where can I find it?
    Thank you, Regards
    JB

    http://jgraph.sourceforge.net/
    http://www.jfree.org/jfreechart/index.html
    Those are two that come to mind. There are probably lots of others.

  • I would like to upgrade my Imac 8,1 from 1 Gb to 4Gb RAM. Apple does not have memory for this Imac but recommended Crucial, Kingston or Ramjet. I have noticed a difference in pricing and would like to know if there are differences in their chips?

    I would like to upgrade my Imac 8,1 (20 inch early 2008) from 1Gb RAM to 4 Gb. Apple no longer provides 800Mhz2DDR2 SDRAM but recommended Crucial, Kingston or RAMjet.
    Are there any difference in these vendors chips as the price range is from $51-$99?
    Thanks, Johng

    I'm coming late to this string because I now have the same issue as gillnfly and you have all solved virtually all of my questions - thanks!  My only other question to add to what you've already said is - I currently have 1 G of memory installed.  Can I ADD a 2G card to get to 3G (probably more than I need), or should cards match if you have more than 1 - i.e., 2 1G cards or replace existing 1G with a 2G, or even 2 2G cards (way more than I need).
    Thanks for your spot-on comments!  I already found the OWC website and you've confirmed that's the best place to go.

  • When does java start

    I would like to know when java starts upon reboots of Solaris machines. I cannot seems to find any startup scripts in the rc directories. Any ideas?

    FWIW, Solaris and Linux don't do any reboots (or
    anything else nasty) during WS install.

Maybe you are looking for

  • How many times can you install iLife 09 onto your Macs?

    My teacher for Video Production wants to update to '09, and we have 5 Macs at our school. He doesn't want to have to buy 5 separate discs, and was wondering how many times the CD Key can be used when you buy just one program.

  • Window 8.1 Merging Files with from Folders With Same Name Together

    I notice folders with the same exact name in the same location will merge together all the files into one folder without any notice to change the name. Is there some way to change this setting? 

  • Video podcasts crashing MBP? Why so?

    System: MBP 2.4GHz with Tiger v10.4.11 and the latest iTunes 7.6.1 and QuickTime 7.4.1 All media are stored on an external FW SATA HD. Problem: Playing most video podcasts crash or freeze my MBP! Doesn't happen to music videos, TV shows and movies. W

  • Mac renaming .vcs files to .ics files without prompting... Can I stop it?

    I use a site that takes my work schedule and generates a .vcs file that I can import into whatever scheduling program I want... When I download the file from the website on my PC, it saves it as a .vcs and everything is fine. When I do the exact same

  • Send idocs or RFC from R/3 to biztalk

    hi All, We have an requirement of transferring master data from R/3 to biztalk whenever any cahnge to the master data is made. We are contemplating using IDocs or RFC to do this transfer. If it were a R/3 to R/3 transfer then I have come across many