How many space is used by an object

Hi @ all,
my english isn't very well but I hope you will understand me.
I have to find out how many space is used by an object at runtime. The goal is to get information about the actual used space by an objectbuffer. (I mustn't use jvmpi or something else)
Do you have an idea?
best regards

Try playing with the following code:
import java.io.*;
class IWantToBeMeasured implements Serializable {
    String[] stringArray = new String[1000]; //-- you'll waste at least 4 * 1000 bytes here...
    byte[] byteArray = new byte[1000]; //-- you'll waste at least 1000 bytes here...
    public IWantToBeMeasured() {
        //-- generate 1000 distinct strings "12345" // so you'll waste at least 5 * 1000 * 2 bytes here...
        for (int i = 0; i < stringArray.length; ++i) {
            stringArray[i] = String.valueOf (12345);
        //-- just fill 1000 bytes, and make all different, to avoid some optimizations
        for (int i = 0; i < byteArray.length; ++i) {
            byteArray[i] = (byte)i;
class Test114 {
    public static void main(String[] args) {
        int estimatedObjectSize = -1;
        try {
            ByteArrayOutputStream baos = new ByteArrayOutputStream ();
            ObjectOutputStream oos = new ObjectOutputStream(baos);
            IWantToBeMeasured iwtbm = new IWantToBeMeasured ();
            oos.writeObject (iwtbm);
            oos.flush();
            estimatedObjectSize = baos.size();
            baos.close();
        } catch (IOException ex) {
        System.out.println ("Estimated object size = " + estimatedObjectSize);
}It prints "Estimated object size = 9154".
Well, do you expect a number that's greater than 15000 here. Why my program printed 9154?
There is a problem here. I know that a string is stored in Unicode in memory, so each character must occupy 2 bytes. But strings are serialized in UTF-8 encoding, that use only 1 byte for each ASCII character. Then the program printed 9154 , that's yet smaller than 4000 + 5000 + 1000.
I leave the problem to you.

Similar Messages

  • How to find out how many memory is used for NIO

    is there any way to find out how many memory is used for nio in a virtual machine. ?
    I know that is possible to find out how many total, free and used memory the heap has by using java.lang.Runtime#totalMemory...
    We sometimes expect errors that it is not possible to create any more connections because of the NIO memory size but the heap is still ok. Today we had an error where 170mbytes of heap where left but it was not possible to create new tcp connections because of an exception:
    javax.naming.NamingException: java.net.SocketException: No buffer space available (maximum connections reached?): connect
    The number of TCP-Connections was ok (<500).
    It would be very nice if someone knows how to find out how the amount of memory that NIO buffers use can be determined within Java 1.4.
    best regards
    benjamin

    We have to use 1.4.2_03. This is because of the special environment we are running on.
    We did also figured out that there are some NIO Memory Bugs but we since we are not allowed to upgrade the used Virtual Machine we have to live with these errors.
    The problem that we currently have is within a Server and because of this circumstance we are trying to find a workaround or way to find out how many memory is allocated. If we would know how to get this value we could restart the servers as a workaround after the value reaches a threshold.
    We are also very sad that we can`t easily upgrade/update to the latest 1.4.2 Version or the newest 1.5 to get rid of these NIO Bugs!

  • With one package of Adobe Creative Suite 2 and the upgrade CS5 how many computers can use it?

    With one package of Adobe Creative Suite 2 and the upgrade CS5 how many computers can use it?

    You have 2 activations and no more.
    Mylenium

  • How can i see how many people are using my apple id without changing the password ?

    how can i see how many people are using my apple id without changing because some people have it

    I'm not sure that you can. Why have so many people got your password? So many in fact, that you don't know how many.
    You can see how many computers are authorised to play any songs you have purchased from the iTunes Store, but that isn't quite the same thing.
    Perhaps a better idea would be to change the password and not let anyone else know what it is. That would at least prevent anyone else from changing it and locking you out of your own account.

  • Need to find out how many users are using Siebel Application

    Hello all,
    I need to find out how many users are using Siebel Application?
    Is there a way I can find out?
    Thanks.
    yasun

    Hi,
    Read the following:
    http://docs.oracle.com/cd/B40099_02/books/SysDiag/SysDiagSysMonitor30.html
    http://docs.oracle.com/cd/B40099_02/books/SysDiag/SysDiagSysMonitor17.html
    For full information about server status and statistics red:
    http://docs.oracle.com/cd/B40099_02/books/SysDiag/SysDiagSysMonitor.html
    T.Abed

  • Using powershell to find out how many people are using the on-prem SkyDrive

    Hi
    Is there a way of using powershell to find out how many people are using the on-prem SkyDrive?
    Thank you.

    Hi,
    According to your post, my understanding is that you wanted to use PowerShell to find out the users who use the on premise SkyDrive.
    As this is the forum for SharePoint Server, I recommend you post your question to the forum for PowerShell or SkyDrive.
    Windows PowerShell forum:
    http://social.technet.microsoft.com/Forums/windowsserver/en-US/home?forum=winserverpowershell
    SkyDrive forum:
    http://answers.microsoft.com/en-us/onedrive/forum/sdsignin?tab=Threads
    Thanks,
    Jason
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Jason Guo
    TechNet Community Support

  • How many times can use setup cartridge?

    How many times can use setup cartrige?
    Can i setup more printers of same model with same setup cartridge?

    We dont need to use the setup cartridges if the printer gets into any problem like ink cartridge rejection or paper jam or any failure.
    Can you let me know what reset are you perfoming, for any hard reset or reset done from front panel menu we dont require any setup cartridges.
    The setup cartridges are required only if there is any printer hardware replacement.
    Although I am an HP employee, I am speaking for myself and not for HP.
    Say thanks by clicking the "Kudos! Star" which is on the left
    Make it easier for other people to find solutions, by marking my answer with "Accept as Solution" if it solves your issue

  • How many transaction key used for Service PO

    Hi,
    Please let me know, how many transaction key used for Service PO...
    In OBYC, we have maintained GBB & WRX Transaction key's for Service PO, Is there any other Transaction key skip???
    Please guide...

    Hi,
    GBB is used for Offsetting entry for inventory posting but for Service procurement WRX Transaction key is used for GR/IR clearing-service.
    NOTE: You may use WRX with new account modifier ZZZ  to triggers GR/IR clearing-service only for service procurement where you need to post all separate GR/IR clearing- material , GR/IR clearing-asset and GR/IR clearing-service and can done with user exit.
    #But in special case GBB can be used with VBR key or copy of VBR as ZBR for default G/L account foe service PO.
    For more check the link:
    http://www.bluemarlinsys.com/ns/0603-03.asp
    Regards,
    Biju K

  • How to find out how many space character in setence (string var) ?

    Dear all Master,
    I need Your help please.
    Topic:
    Script Editor.
    My System:
    -CUCM 7.0
    -UCCX 7.0 premium
    -Nuance recognizer 9.0
    Question:
    ABC = string var.
    ABC = "this is sample"
    2 space character in ABC string var.
    How to find out how many space character in ABC var ?
    Regards,
    Susanto

    Hi
    Create a int variable called whatever you want, then insert a SET step.
    Set the variable to the new int you created, and then paste this into the 'value' field:
    String[] myarray = teststring.split(" ");
    return myarray.length -1 ;
    Basically it splits the string into chunks each time it hits the " " character.
    This results in an array of the resulting chunks (i.e. words), which is one more than the number of spaces. -1 from that, and you have your int variable set to the number of spaces.
    Regards
    Aaron
    Please rate helpful posts...

  • User Profile Services:How get to know how many user are using my site.

    Hi,
    User Profile Services:How get to know how many user are using my site.
    Recently i have done migration sharepoint 2010 to sharepoint 2013,I did not migrate USer profile services because less user are using user profile here,but i need to know how many few uer are using my site for data store.
    Is any why we can get to know  user name who are using my site document library and other things.
    Hasan Jamal Siddiqui(MCTS,MCPD,ITIL@V3),Sharepoint and EPM Consultant,TCS
    |
    | Twitter

    Fallowing command shows only count of my site user ,I need to know how many upload data on my site
    Hasan Jamal Siddiqui(MCTS,MCPD,ITIL@V3),Sharepoint and EPM Consultant,TCS
    |
    | Twitter

  • How do I verify how many devices are using my apple ID?

    I would like to know how many devices are using my apple ID?

    http://support.apple.com/kb/HT4627

  • How to change how many cores to use in after effects cs4

    so i raced my laptop vs my desktop
    desktop:intel core 2 quad 2.33 ghz  4 gigs of ram
    laptop: intel core 2 duo 1.83 ghz 4 gigs of ram
    and my desktop beat it by a little bit
    kinda sad
    then i went to
    edit>preferences>memory&multiprocessing
    then i clicked on render multiple frames siultanesously [clicked on the check box]
    and then relized that
    my laptop said
    actual cpu's that will be used: 2
    my desktop says
    actual cpu's that will be used: 1
    that is why my desktop was running so slow1
    can someone help me change that?

    Hoonathan:
    Even though in After Effects CS4 there's a new preference item to set how many cores to use (or how many to leave idle for other purposes), you have to bear in mind that this feature works by launching a number of background processes (ie, headless versions of the full application) according to the number of cores in your machine. Because of this, the more cores you have, the more RAM you need for the feature to work at all (or it will simply refuse to launch the background processes because of insufficient RAM). For a quad-core machine, 8 GB of RAM would be the minimum recommended amount (you could probably get all 4 processes to launch with 6 GB, but I don't think that would be a good idea). You should be able to have at least 2 cores used in your desktop system, though. Go to Preferences > Memory and Multiprocessing. Of course, enable "Render Multiple Frames Simulataneously" and make sure "CPUs to leave for other applications" is set to 0 (zero).  Also, check that the minimum allocation (ie, minimum RAM amount per core for the processes to launch) is 0.5 GB.
    If the number of cores is still 1, try moving the Longer RAM preview/Faster rendering slider and see if at some point, it enables the second core.
    In the long run, upgrading your desktop system to 8 GB of RAM (or more, if the motherboard allows it) would be the best move.
    Of course, for an in-depth description of all settings involved, take a look at the Memory & Multiprocessing preferences section in After Effects Help.

  • How many times can use in different computer my Adobe Illustrator CS6 under the TLP License Program?

    How many times can use in different computer my Adobe Illustrator CS6 under the TLP License Program?

    You have 2 activations per license.
    Mylenium

  • How many primary keys use in one table

    Hi,
    Please help me. Maximum How many primary keys use with in one table
    Regards,
    Sunil Kumar.T

    Hi,
    For my knowledge, It depends on the Database & version u r working.. Right..
    This is a sample description what I seen for a Database...
    Technical Specification of SAP DB Version 7.4
    Description                            Maximum Value
    Database size                    32 TB (with 8 KB page size)
    Number of files/volumes per database64...4096, specified by a configuration parameter
    File/volume size (data)      518 ...8 GB (dependent on operating system limitations)
    File/volume size (log)1      6 TB (dependent on operating system limitations)
    SQL statement length>=  16 KB (Default value 64 KB, specified by a system variable)
    SQL character string lengthSpecified by a system variable
    Identifier length                32 characters
    Numeric precision              38 places
    Number of tables unlimited
    Number of columns per table (with KEY)  1024
    Number of columns per table (without KEY)  1023
    Number of primary key columns per table  512
    Number of columns in an index  16
    Reward Points if useful

  • How many memory is used for the process of one connection?

    Hi,
    how many memory is used for the process of one connection in unix
    when the user connects to the database?
    Thanks,

    Write some queries using v$sesstat, v$statname, v$session to find the statistics for different stats. Query name from v$statname and find whatever you wants. I don't think there is a common rule that tells how much memory will be used for each connection, it depends on different factors like , resources available, type of databases, database memory settings etc.
    Example query.
    select s.osuser osuser,s.serial# serial,se.sid,n.name,
    max(se.value) maxmem
    from v$sesstat se,
    v$statname n
    ,v$session s
    where n.statistic# = se.statistic#
    and n.name in ('session pga memory','session pga memory max',
    'session uga memory','session uga memory max')
    and s.sid=se.sid
    group by n.name,se.sid,s.osuser,s.serial#
    order by 2
    ;

Maybe you are looking for