How to figure out the size of an object - java out of heap memory error

Hi all,
I am using an object that I found in a library that I didn't create so I don't know its internal state or members.
I created a single one of these objects and I call announce() on this object which just sends a UDP announcement over the channel to notify listeners. However, after a message #124,288 I get a java out of heap memory error.
I am wondering if this announce() method is causing the state of the object to grow with every call...it seems unlikely but I want to check to see if it's reserving a growing amount of heap memory without ever allowing it to free.
My question is how can I check how big the object is within my program? I'd like to check, for instance, at every 10,000 messages sent how much memory the object is taking up. Is there a method call for that? Would I have to use some kind of debugger or memory monitor? I would like something easy to use.
Please let me know, and thanks in advance.
Julian

jboolean23 wrote:
Thanks for the quick reply.
I say it's unlikely that the methods I call are filling up heap memory because I have one Message object. This one Message has a myMsg String member. Whenever I want to change the message I call myMsg = "anewstringhere". And then I do myMessageObject.announce(); And for that reason i say I only have one Message object. The only thing added to the heap would be the strings that I replace myMsg with. The old references to myMsg are no longer valid and should be garbage collected..
Unless of course if you are calling intern() on them.
so here's my train of thought (and this isn't what my actual code looks like):
myMessageObject.myMsg = "hello" //creates a string on the heap? I assume this is equivalent to saying myMsg = new String("hello")No they are not the same.
The text literal will be in the intern space. Both code fragments would do that.
The second example would create a second instance of String(). That second instance would be cleaned when no longer referenced. But the literal will not.
Is my thought process correct? You are calling a third party library right so mock it (write a simple replacement that does the minimal correct functionality.) Substitute it in your code. And then run. If it still fails then the problem is in your code. If not then it is either in the library or the way that you use the library.

Similar Messages

  • Urgent: How to find out the size in bytes of java object

    Hi Experts,
    We've a requirement that we need to find out the size of a java object at run time, is there a direct java API to get the size of a composite object in memory?
    Here is my requirement: We are adding string objects (which is an xml string of considerable size) into a List. After reaching certain size limit (lets say 5MB) of the list i need to put this data into DB as a CLOB. So every time I add a string object to the list, I need to see if the total size of the list exceeds the limit and if yes, flush the results into DB.
    I am not sure if java has a direct API for this, if not what is the beast way to do it, it s critical requirement for us.
    It would be really great if someone could help us out.
    Thank you,
    -Shibu.

    >
    We've a requirement that we need to find out the size of a java object at run time, is there a direct java API to get the size of a composite object in memory?
    Here is my requirement: We are adding string objects (which is an xml string of considerable size) into a List. After reaching certain size limit (lets say 5MB) of the list i need to put this data into DB as a CLOB. So every time I add a string object to the list, I need to see if the total size of the list exceeds the limit and if yes, flush the results into DB.
    I am not sure if java has a direct API for this, if not what is the beast way to do it, it s critical requirement for us.
    It would be really great if someone could help us out.
    >
    Could you explain your actual requirement a little more fully.
    1. Is each individual string a separate XML string? Or is it just a fragment? Why would you just concatenate them together into a CLOB? That won't produce valid XML and it won't let you easily separate the pieces again later. So provide a simple example showing some strings and how you need to manipulate them.
    2. Are you using these xml strings in Java at all? Or are you just loading them into the database?
    For example if you are just loading them into the database you don't need to create a list. Just create a CLOB in Java and append each string to the CLOB. Before you append each one you can check to see if the new string will put you over your length limit. If it will then you write the CLOB to the database, empty the CLOB and start appending again to the new clob instance.
    If you explain what you are really trying to do we might be able to suggest some better ways to do it.

  • How do I determine the size of an object on a particular layer?

    Whether it's a rectangle, circle, line, etc. how do I determine what the size of an object is on a particular layer?

    Right click on the rulers and set the scale to pixels in the dialog
    Go to View>new guide and select the position of the guide lines along horizontal and vertial axes
    Window>info brings up the Info Palette. The information in the right lower corner provides a readout of any selection that you make, e.g. with the marquee tool
    View>grid allows one to bring up a non-printable grid which is useful for orientation. The grid can be set up with subdivisions to suit via Edit>preferences>guides and grid
    You can open a duplicate layer at the top of the stack, then using the brush tool create a straight line for visual projection. The layer can be deleted at any time. To create a straight line, click on the begin point, hold down the shift key, and click on the end point
    Hope that one of these options is useful for your purpose. Please post your progress.

  • How can I know the size of a JViewport laid out in BorderLayout.CENTER?

    I have a JPanel inside a JScrollPane. The scroll pane is laid out inside of BorderLayout.CENTER. I need to know the size of the JViewport to do stuff like centering and zooming.
    Where can I find the size? All these methods return 0 values for X and Y:
    myScrollPane.getViewport().getSize()
    myScrollPane().getSize()
    myScrollPane.getHorizontalScrollbar().getValue()
    Yes, even the scrollbars won't give me any values! It's all because of the BorderLayout!
    Any ideas? Thanks.

    Sounds like you are accessing the sizes before the views are realized (that is before a call to frame.pack()/show()) They are available only after the layoutManager had a go on it. What is available earlier are preferred/min/max, though.
    Greetings
    Jeanette

  • How do I determine the size of an object?

    After an object is instantiated, is there anyway to determine its size (in bytes)?

    Why do you want to know? Java handles memory management for you.
    IIRC for Sun JVM 1.4:
    Objects: four bytes for each reference, boolean, byte, short, int, float or character field, eight bytes for each long or double field, plus sixteen bytes header information.
    Arrays: length * (four for reference, int or float; one for boolean or byte; two for short or character; eightfor long or double), plus sixteen bytes header information.
    Pete

  • How do I figure out the size of an image in my iPhoto. How do I know if it is Kilobytes or megabytes. I assume Megabytes are larger than kilobytes and gigabytes are largest.

    How do I figure out the size of an image in my iPhoto. Soe applications require a certain size and I have no way of knowing what they are.
    Please confirm that Kilobytes are smaller than megabytes and gigabytes are the largest.

    You're correct, Kilobytes are smaller than megabytes and gigabytes are the largest.
    When you attach the images to an email, look on the bottom line for the total size of the email.  You can also change the image from Actual size to medium or small.

  • How do I change the size of the tools and the text for the menus in Photoshop?  I need a magnifying glass in order to make out what they are.

    How do I change the size of the tools and the text for the menus in Photoshop?  I need a magnifying glass in order to make out what they are.

    Okay, I've figured it out, so I'm going to answer my own question in hopes that it may help anyone else that would like to actually be able to see what they're doing when using Photoshop CC 2014 on a high resolution screen.
    1.  Open Photoshop.
    2.  Select Preferences from the Edit Menu, then select General.
    3.  Change the HUD Color Picker to Hue Strip (Medium).
    4.  Select Interface from the Preferences menu on the left side of the dialog box.
    5.  Change the UI Font Size to Large in the Text area of the Preferences dialog box.
    6.  Select Experimental Features from the Preferences menu on the left side of the dialog box.
    7.  Select Scale UI 200% for high-density displays (Windows only).
    8.  Click on OK, then Exit/Quit Photoshop.
    9.  Open Photoshop and everything should be readable.

  • How do i find out the size of a webpage?

    how do i find out the file size of a webpage im viewing in my
    browser? and how do i find out the size of a webpage of my
    own?

    Hello,
    Try this site out.
    Just enter your URL.
    http://www.websiteoptimization.com/services/analyze/
    Take care,
    Tim
    "name294" <[email protected]> wrote in
    message
    news:gpiuqv$9on$[email protected]..
    > how do i find out the file size of a webpage im viewing
    in my browser? and
    > how do i find out the size of a webpage of my own?

  • How do I find out the size of each individual element within a photoshop file as need to replace some elements?  Thanks :)

    How do I find out the size of each individual element within a photoshop file as need to replace some elements?  Thanks

    What do you mean by "Elements"?
    Elements in a flat image or Layers?
    Could you please post a screenshot with the Layers Panel visible?

  • How to find out the size of files transferred over the SQL * Net?

    I am trying to test the Advanced Compress (AC) for 11g Data Guard. When the AC is turned on, the archived log files are supposed to be compressed on the primary database server and sent over SQL*Net, then decompressed on the standby db server. We will see the file sizes are the same on both primary and standby servers. I want to verify that the AC works by monitoring how much data are sent over SQL*Net. Per Oracle, AC uses 35% less of the bandwith. That means the size of the files transferred should be at least 65% of the original size.
    Is there a way to find out the size through Oracle utilities? If not, how to find out by OS utilities? OS is Solaris 5.10.
    Thanks.

    I'm not sure this can be done via SQL*Net, but a network packet sniffer between the two servers should be able to help - you might want to contact your network team.
    HTH
    Srini

  • How can i find out the size of video on my iphone 5?

    How can i find out the size of video on my iphone 5?

    As far as I've known, all iPhones (3G/3GS/4/4S/5) sold in China (probably only in China) have this low battery alert sound.
    So called "localization" or what...
    Actually many people found it annoying coz it plays even when the phone is switched to SILENT. However no solution has been found so far
    PS: reeeeeeeally hope Apple could see this thread and at least give Chinese users an option to switch it off!!
    <Edited By Host>

  • HT1349 How can i find out the size and length of my playlist?

    How can i find out the size and length of my playlist? Anybody?

    It shows up in iTunes on your computer as seen here:

  • How to find out the size of a database?

    I'm not an oracle dba but a report developer. I'd like to find out the size of my database.
    Is this possible using simple query?

    An oracle database consists of data files, redo log files, control files, temporary files. Whenever you say the size of the database this actually means the summation of these files.
    select a.data_size+b.temp_size+c.redo_size+d.controlfile_size "total_size in MB"
    from
    ( select sum(bytes)/1024/1024 data_size from dba_data_files ) a,
    ( select nvl(sum(bytes),0)/1024/1024 temp_size from dba_temp_files ) b,
    ( select sum(bytes)/1024/1024 redo_size from sys.v_$log ) c,
    ( select sum(BLOCK_SIZE*FILE_SIZE_BLKS)/1024/1024 controlfile_size from v$controlfile) d;
    here
    a is megabytes allocated to ALL datafiles
    b is megabytes allocated to ALL TEMP files
    c is megabytes allocated to ALL redo-logs
    d is megabytes allocated to ALL control files
    Nimish Garg
    Software Developer
    *(Oracle & ASP.NET)*
    Indiamart Intermesh Limited, Noida
    To Get Free Oracle & ASP.NET Code Snippets
    Follow: http://nimishgarg.blogspot.com

  • How do you see the size of your hard drive

    I am new the the MAC world and I am trying to figure out some things.  How do you see the size remaining on your hardrive?

    If you have a folder open or dubble click on your hard drive you, can turn on the status bar which will show you available disc space:

  • How do I determine the size of my iPhoto library?

    I am running out of disk space and I assume that it is due to my photos.
    #1 - how do I determine if this is the case?
    #2 - how can I figure out the size of my library so I buy the correct sized external HD?
    #3 - what is the best practice for moving iPhoto to an external HD? Do people move over only "older" photos or just run iPhoto off the external HD completely?
    Thank you so very much!
    Jen

    #2 - how can I figure out the size of my library so I buy the correct sized external HD?
    Go to your Pictures Folder and find the iPhoto Library there. Use the Finder's File -> Get Info command to get the size of the Library. When you purchase an extenral disk, make sure to format it Mac OS Extended (Journaled). Also, allow room to grow.
    #3 - what is the best practice for moving iPhoto to an external HD? Do people move over only "older" photos or just run iPhoto off the external HD completely?
    There isn't a "best practise" there's only what you need to do. IF the Library is on the external, then you can only view it with the external attached. Are you on a Laptop? Desktop? If you're on a desktop it probably doesn't matter. If you're on a Laptop it might.
    Regards
    TD

Maybe you are looking for

  • Sort field in VF31

    Hi, Pls anybody let me know what is the functionality of field "Sort order" in VF31 screen? what is the meaning of this feild and for what purpose we use this field? thanks & Regards, Srikanth.P

  • Creation of a product description field of length 250 car. used for search?

    Hi all, we need to create a specific description field for products  with a length of 250 (the standard description is too short at 40 car, =>table COMM_SHTXT) . That field should also be added to the search criteria. What would be the best solution

  • How Can I download Aps in orker country?

    Hi! I want to download a ap that only exist in USA, so when i press the ad in the Internett I get a message from Apstore that the ap only exist in USA and if I would like to change country, but when i press download it said that my aple Akcount only

  • Activation error

    I am unable to activate my Acrobat 7.0 Prof. "Activation was unseccessful because the activation server is not availabel at this time." Error code 24:24 What can I do?

  • Is anyone else having issues with Aperture 3 since downloading Lion?

    Hi All, Is anyone else having issues with Aperture 3 after downloading the Lion update? Aperture 3 is running so ssssslllloooowwww !!! I am a sports photographer who needs this to run the way it used to with Snow Leopard. Any suggestions????? Thanks,