Is there a way to find the class objects memory size?

Hi Friends,
Please help.
Is there a way to find the number of Objects created and total size?
For example:
class AgeRecord
int start;
int end;
AgeRecord(int start, int end)
this.start = start;
this.end = end;
In a loop if I create 1000 objects, how will I get the total memory size
Thanks and Regards
JG

You might find this useful...
package forums;
http://weblogs.java.net/blog/dwalend/archive/2007/11/the_thing_about.html
http://forums.sun.com/thread.jspa?threadID=457279&start=30&tstart=0
http://www.velocityreviews.com/forums/t364574-size-of-boolean-type.html
The JLS doesn't specify the size of a boolean, leaving it upto the JVM
implementor to define. Sun's JVM stores booleans as:
(1) a boolean is-an int; i.e. a signed 32 bit twos-compliment integer.
    At face value, this is an innordinate waste of space, but Java uses a
    32-bit stack frame, and most (modern) CPU's use a 32-bit word anyway,
    so the wasted space is worth the CPU cycles, and it's simple.
(2) a boolean[] is-a byte array, using 1 byte per element, rounded up to the
    nearest 8, plus 8 bytes for the array-object itself.
    For example: boolean[] bools = boolean[100];
    100 mod 8 = 4; so that'd be 104 bytes + 8 bytes = 112 bytes.
    So, let's dis/prove the contention by experiment.
    1,000,000 mod 8 = 0 so 1,000,000 + 8 bytes for the array = 1,000,008
class BooleanArraySizeTest
  public static void main(String[] args) {
    final Runtime rt = Runtime.getRuntime();
    System.out.println("The contention is that each iteration should use 1,000,008 bytes.");
    try {
      long before, after;
      final int TIMES = 32;
      boolean[][] bools = new boolean[TIMES][];
      for (int i=0; i<TIMES; i++) {
        before = rt.totalMemory() - rt.freeMemory();
        int n = 1000*1000-(TIMES/2)+i;
        bools[i] = new boolean[n];
        after = rt.totalMemory() - rt.freeMemory();
        System.out.print(n);
        System.out.print('\t');
        System.out.print(after-before);
        System.out.println();
    } catch (Exception e) {
      e.printStackTrace();
999984 used=1000000 bytes
999985 used=1000000 bytes
999986 used=1000000 bytes
999987 used=1000000 bytes
999988 used=1000000 bytes
999989 used=1000008 bytes
999990 used=1000008 bytes
999991 used=1000008 bytes
999992 used=1000008 bytes
999993 used=1000008 bytes
999994 used=1000008 bytes
999995 used=1000008 bytes
999996 used=1000008 bytes
999997 used=1000016 bytes
999998 used=1000016 bytes
999999 used=1000016 bytes
1000000 used=1000016 bytes
1000001 used=1000016 bytes
1000002 used=1000016 bytes
1000003 used=1000016 bytes
1000004 used=1000016 bytes
1000005 used=1000024 bytes
1000006 used=1000024 bytes
1000007 used=1000024 bytes
1000008 used=1000024 bytes
1000009 used=1000024 bytes
1000010 used=1000024 bytes
1000011 used=1000024 bytes
1000012 used=1000024 bytes
1000013 used=1000032 bytes
1000014 used=1000032 bytes
1000015 used=1000032 bytes
ENVIRONMENT:
  Microsoft Windows [Version 6.0.6000]
  Copyright (c) 2006 Microsoft Corporation.  All rights reserved.
  C:\Users\Administrator>java -version
  java version "1.6.0_12"
  Java(TM) SE Runtime Environment (build 1.6.0_12-b04)
  Java HotSpot(TM) Client VM (build 11.2-b01, mixed mode, sharing)
*/Cheers. Keith.

Similar Messages

  • Is there a way to find the serial number in these files so that I can reinstall the full version?

    I had to restore from backup to a new hard drive, and only have part of my Adobe Photoshop installation. Is there a way to find the serial number in these files so that I can reinstall the full version?  I have only part of the documentation so this is the best way I see to get the full version back.

    Hello brad,
    you did purchase your product from these firms like Amazon, so you didn't get a serial number, only a code with which you can request a serial number from Adobe. Please have a look at http://helpx.adobe.com/x-productkb/global/find-serial-number.html. (Start here: How did you purchase your product?)
    The following part, so I just see at least, ceased to exist on my Adobe website, everything takes place in the link from above. I leave it as an info yet, it might still fit for you. For this purpose, please click your way through to your Adobe Store and find the button "Get Serial Number". Fill in the form and after a while you will get the real serial number.
    Additionally you should have a look at Adobe's database, to see what's stored/saved about your accounts. Here you will find general infos about your Adobe Account.
    On the other hand, if necessary and for further questions click through http://helpx.adobe.com/contact.html and if "open" please use the chat, I for may part had the best experiences. I quote from Adobe's employee Preran: The chat button is activated as soon as there is an agent available to help.
    Hans-Günter

  • Is there a way to find the list of PCs and iDevices connected to my Itunes Match?

    Is there a way to find the list of PCs and iDevices connected to my Itunes Match?

    Is there a way to find the list of PCs and iDevices connected to my Itunes Match?

  • I have files that freeze my programs whenever I try to open ANY file. Is there a way to find the exact files causing the crash?

    I have files that are freezing my programs (adobe; after effect and photoshop, as well as maxon cinema 4d). Whenever I try to import ANY file from within the program it doen't even let me select the file I need before freezing. I have moved all files off my desktop and into my dropbox, and it now allows me to import files/search for files on the desktop but NOT dropbox, once I go to dropbox it freezes again. I am assuming there are files within dropbox now that are crashing my programs. The problem is I have a lot of files in there and would like to remove the corrupt ones so that I can use my programs without freezing. Is there a way to find the exact files causing the crash?
    This has happened a couple of times and each time I have to move all my files off my desktop, so there must be a type of file doing this, I just don't know what files they are.
    Mac Book Pro 15" running OSX 10.9
    Processor  2.3 GHz Intel Core i7
    Memory  16 GB 1600 MHz DDR3
    Graphics  Intel Iris Pro 1024 MB
    ANY help would be greatly appreciated! It is making it really hard to get work done. THANKS!

    This error sounds to me like you have/had BootCamp Windows installed and then removed, posible ?
    If so (and even if not so), try restating your MBA while holding down the alt/option-key until you get to the Boot Selection Screen.
    Choose to boot OSX.
    Once in OSX go to System Preferences then Startup Volume and set your OSX to be the default.
    Hope it helps
    Stefan

  • My mac book wont recognize my ipod. My Ipod will make the initial connected sound saying its charging but otherwise theres no way of finding the Ipod anywhere on the computer or Itunes.

    My mac book wont recognize my ipod. My Ipod will make the initial connected sound saying its charging but otherwise theres no way of finding the Ipod anywhere on the computer or Itunes. Please help with anyway I can get the Ipod recognized so I can download music from Itunes to my Ipod. Thanks in advance.

    Hello xerxes.nashion,
    It sounds like your iPod is not recognized by iTunes or your MacBook Pro.  I recommend following the steps in the article below for an issue like this:
    iPod not recognized in iTunes and Mac desktop
    http://support.apple.com/kb/TS1410
    Thank you for using Apple Support Communities.
    Best,
    Sheila M.

  • Is there a way to find the Time Duration for applying a Patch?

    Dear Legends,
    Is there a way to find the Installation or Applying time can be gauged for a PATCH, so that it will be useful to provide the DOWNTIME of the server.
    Thanks in Advance
    Regards,
    Karthik singh

    karthiksingh_dba wrote:
    Dear Legends,
    Is there a way to find the Installation or Applying time can be gauged for a PATCH, so that it will be useful to provide the DOWNTIME of the server.
    Thanks in Advance
    Regards,
    Karthik singhNot until you test the patch and install it yourself on one of the instances. Once you apply the patch, you can check the patch log file or the patch analysis report or AD_BUGS table.
    https://forums.oracle.com/forums/search.jspa?threadID=&q=Patch+AND+Analysis+AND+Report&objID=c3&dateRange=all&userID=&numResults=15&rankBy=10001
    You can run the patch with apply=n but this will let you to test the patch before applying it only.
    http://docs.oracle.com/cd/E18727_01/doc.121/e12148/T531058T531065.htm#adptpptpbai
    http://docs.oracle.com/cd/E18727_01/doc.121/e12148/T531058T531062.htm#adptpaucla
    Thanks,
    Hussein

  • I have an iPad1 which I have reset and am preparing to give to a kid.  I now find that I can't reinstall many apps as they now seem to require IOS 6 or greater.  This is IOS 5 and can't be upgraded.  Is there a way to find the older versions of the apps?

    I have an iPad1 which I have reset and am preparing to give to a kid.  I now find that I can't reinstall many apps as they now seem to require IOS 6 or greater.  This is IOS 5 and can't be upgraded.  Is there a way to find the older versions of the apps?

    One of these links may help:
    iOSSearch - search the iTunes store for compatible apps.
    Vintapps 3.1.3 - paid app.
    Apple Club - filter apps by iOS version.

  • InCopy workflow in InDesign: Is there a way to find the document in which an ICML file has NOT been checked IN again before saving the doc?

    The situation:
    We are working with the InCopy feature (checking in and checking out ICML files).
    The problem:
    I might have saved a document with an ICML file still checked out.
    The question:
    Is there a way to find out which document was saved with the ICML file still checked out?
    or in other words:
    Is there a way to find the document in which an ICML file has NOT been checked IN again before saving the doc?
    Thanks for any help!

    Hello Sumit Singh,
    thank you for your answer and your reasonable recommendation. Unfortunately, this only works when the ICML content is used in one INDD file. In our case, we use ICML content in multiple docs (various manuals with the same safety instructions, warranties, adresses etc.).
    So, is there a way to trace back where an ICML has been used?
    Is it possible to find out in which document the ICML is still checked out?

  • Is there a way to find the number of downloads of music from itunes store?

    Hi,
    Is there any way to find the number of downloads of each music file available on itunes store. If not exact no of downloads but atleast a relative term to find the rank of the music track From any API
    Thanks
    Sandeep

    A: Is there a way to read the number of active sequence executions from the Engine?

    Scott,
    > One way of handling the issue of init once a set of instruments is to
    > create a new sequence file that has a sequence to init and a sequence
    > to close the instruments. Assuming that you always terminate a
    > sequence and do not abort them, you could add a ProcessSetup and
    > ProcessCleanup callback sequences to the client sequence file that
    > using these instruments. These callbacks are automatically called by
    > the process model in both the Single Pass and Test UUTs execution
    > entry points. The callback sequences could call the init and close
    > sequences for the hardware. In the hardware sequence file you could
    > reference count the number of execution that init and close by setting
    > the file globals in the sequence file to be shared across executions
    > and then add a numeric value that keeps track of references for the
    > instruments. The init sequence adds to the count, and the close
    > sequence subtracts from the count. The init sequence inits the HW if
    > the count is 0->1 and the close sequence closes the HW if the count is
    > 1->0.
    >
    > This is one of many ways in TestStand that this could be done, not to
    > mention that this could also be done in a similar way in a LabVIEW VI
    > or DLL directly.
    That sounds like it will work. I'll try adding a client count
    increment/decrement in the DLL initialize and terminate functions. This
    should essentially perform the same tasks as the callback scheme you mention
    above, no?
    The reason I didn't think the 'client counting' scheme would work initially
    was I mistakenly thought that the termination function would not get called
    under Terminate conditions. Since Terminate conditions happen a LOT during
    our initial debug of new UUT types, I didn't think that would be acceptable.
    I forgot that lacing the terminate funciton in a cleanup step group, I can
    force it to be called in Terminate conditions.
    > If you abort an execution then the reference counting idea above would
    > fail to decrement properly. That might b... [Show more]

    Read other 5 answers

  • Is there any way to find the serial number of an ipod touch that is no hooked up to the computer?  It was stolen and we need the number to give to the police.

    Is there any way to find the serial number of an ipod touch that is no hooked up to the computer?  It was stolen and we need the number to give to the police.

    If the product was registered, the serial number should be here, under My Products:
    https://supportprofile.apple.com/MySupportProfile.do

  • HT4061 Is there another way to find the serial number with only your apple ID and password because apparently I never backed up my iPhone 5?

    Is there another way to find the serial number with only your ID and password because apparently I never backed up my device on my computer?

    If you registered it with Apple, you could try:
    supportprofile.apple.com
    Use your Apple ID and password to log in

  • HT1391 Is there a way to find the serial number for a devise from ITunes? I need it to try and track it as it was stolen

    Is there a way to find the serial number for a devise from Itunes? I need the number for a device that was stolen.

    How to find serial number

  • Is there a way to untag the tagged object?

    Is there a way to untag the tagged object in JVMTI ?
    Thanks, David

    In the "Object Tags" subsection of the "Heap" section in the JVM/TI spec:
    Setting a tag to zero makes the object untagged.

  • Is there a way to find the total "ON" time on my MacPro?

    I was wondering if there was a way to find the total system "ON" time or usage time on my MacPro since I first purchased it?

    I don't believe there is any recordation of that, but someone else may know better. There is, however, a record of how much time the computer has been in use since the last restart: open the Terminal application in the Utilities folder and at the prompt enter "uptime" (without quotes) and press RETURN.

  • Is there a way to find the temporary table that are created or read during?

    Hi All,
    I'm working on performance optimization where I have to find the temporary tablespaces that are created or read during runtime? Is there any way to find it?
    Can you please also tell me how the temporary tables are created? And after each run time whether the data is getting deleted or the whole table is getting deleted?
    Whether these tables are created only during runtime? What are the naming conventions for all the temporary tables that are created?
    Is the table creation has anything to do with Delta or Full load?
    Regards,
    Kartik

    Stephen Tyler Bloom wrote:
    When they come out with the next garageband, they should add that feature .
    be sure to let Apple know:
    http://www.bulletsandbones.com/GB/GBFAQ.html#sendfeedback
    (Let the page FULLY load. The link to your answer is at the top of your screen)

Maybe you are looking for