Howto determine Object size in memory?

HI there!
I know the JVM has a function which prints out a list of all obejcts currently instantiated with the object size and the number how many objects of this type are alive, but I dont know anymore howto enable this feature.
My Profiler does not show this information :-(
Any ideas?
Thanks in advance, lgClemens

Read in another thread that you coudl do like this:
  public static long calculateMemoryUsage(ObjectFactory factory) {
    System.gc(); System.gc(); System.gc(); System.gc();
    System.gc(); System.gc(); System.gc(); System.gc();
    System.gc(); System.gc(); System.gc(); System.gc();
    System.gc(); System.gc(); System.gc(); System.gc();
    long mem0 = Runtime.getRuntime().totalMemory() -
      Runtime.getRuntime().freeMemory();
    Object handle = factory.makeObject();
    System.gc(); System.gc(); System.gc(); System.gc();
    System.gc(); System.gc(); System.gc(); System.gc();
    System.gc(); System.gc(); System.gc(); System.gc();
    System.gc(); System.gc(); System.gc(); System.gc();
    long mem1 = Runtime.getRuntime().totalMemory() -
      Runtime.getRuntime().freeMemory();
    return mem1 - mem0;
public interface ObjectFactory {
  public Object makeObject();
}Gil

Similar Messages

  • Calculate Object size in memory

    I have some requirement like for testing i want to find out the MEMORY used by jsp sessions.My sessions contain three objects.So how can i find out the memory sixe these objects will consume..
    thanks
    manoj

    the certain size of an object depends on the implementation of the jvm and may vary between different versions.
    if you want to estimate the size of an object in memory sum the sizes of all fields and the fields of its superclasses together and if the object has objects as fields add the sizes of their fields too and dont forget the sizes of all fields in the subclasses.
    additionally there is an overhead you carry inwith each object (for vtable, runtimetype and other internal stuff), additionally the fields might be padded in memory to that 1 byte would comsume 4 bytes in memory instead 1.
    if you want to estimate the size of a certain object call System.gc(), look for freeMemory(), then allocate allocate a huge array of the certain object, then call System.gc() again and see the difference of what is returned by Runtime.getRuntime().freeMemory().

  • 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

  • Determine the Size of an Object in ObjectInputStream

    Hi all,
    I have a quick question. I have a class that is being written over a socket using ObjectOutputStream and ObjectInputStream. I want to be able to set the buffer size of the socket to fit only ONE object. Can anybody tell me how to determine the size of that object?
    (Note, the object has a Properties object within it, but for the time being, it can be assumed that properties object will always be the same.)
    - Adam

    Having written it to the outputStream, thought, can
    the size be determined somehow by the inputStream?No, it can't
    This is related to my previous question (on Pushlets
    and Thread Priorities). I didn't read that one.
    I believe that it's possible
    that multiple threads are trying to write to the
    socket at the same time, and I cannot synchorize the
    input stream to get a lock on it. Do you mean the outputstream? Why can't you synchronize the method that writes to the outputstream?
    I thought this
    might be causing the data to not be sent over the
    socket until all the threads have finished. That doesn't sound correct. But you could call the flush method when an object is written.
    I
    figured if I reduced the size of the socket buffer,
    it would only accept a single object, eliminating
    this problem?I don't think so.
    /Kaj

  • How Can I Determine the Size of the 'My Documents' Folder for every user on a local machine using VBScript?

    Hello,
    I am at my wits end into this. Either I am doing it the wrong way or it is not possible.
    Let me explain. I need a vb script for the following scenario:
    1. The script is to run on multiple Windows 7 machines (32-Bit & 64-Bit alike).
    2. These are shared workstation i.e. different users login to these machines from time to time.
    3. The objective of this script is to traverse through each User Profile folder and get the size of the 'My Documents' folder within each User Profile folder. This information is to be written to a
    .CSV file located at C:\Temp directory on the machine.
    4. This script would be pushed to all workstations from SCCM. It would be configured to execute with
    System Rights
    I tried the script detailed at:
    http://blogs.technet.com/b/heyscriptingguy/archive/2005/03/31/how-can-i-determine-the-size-of-the-my-documents-folder.aspx 
    Const MY_DOCUMENTS = &H5&
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objShell = CreateObject("Shell.Application")
    Set objFolder = objShell.Namespace(MY_DOCUMENTS)
    Set objFolderItem = objFolder.Self
    strPath = objFolderItem.Path
    Set objFolder = objFSO.GetFolder(strPath)
    Wscript.Echo objFolder.Size
    The Wscript.Echo objFolder.Size command in the script at the above mentioned link returned the value as
    '0' (zero) for the current logged on user. Although the actual size was like 30 MB or so.
    I then tried the script at:
    http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_27869829.html
    This script returns the correct value but only for the current logged-on user.
    Const blnShowErrors = False
    ' Set up filesystem object for usage
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objShell = CreateObject("WScript.Shell")
    ' Display desired folder sizes
    Wscript.Echo "MyDocuments : " & FormatSize(FindFiles(objFSO.GetFolder(objShell.SpecialFolders("MyDocuments"))))
    ' Recursively tally the size of all files under a folder
    ' Protect against folders or files that are not accessible
    Function FindFiles(objFolder)
    On Error Resume Next
    ' List files
    For Each objFile In objFolder.Files
    On Error Resume Next
    If Err.Number <> 0 Then ShowError "FindFiles:01", objFolder.Path
    On Error Resume Next
    FindFiles = FindFiles + objFile.Size
    If Err.Number <> 0 Then ShowError "FindFiles:02", objFile.Path
    Next
    If Err.Number = 0 Then
    ' Recursively drill down into subfolder
    For Each objSubFolder In objFolder.SubFolders
    On Error Resume Next
    If Err.Number <> 0 Then ShowError "FindFiles:04", objFolder.Path
    FindFiles = FindFiles + FindFiles(objSubFolder)
    If Err.Number <> 0 Then ShowError "FindFiles:05", objSubFolder.Path
    Next
    Else
    ShowError "FindFiles:03", objFolder.Path
    End If
    End Function
    ' Function to format a number into typical size scales
    Function FormatSize(iSize)
    aLabel = Array("bytes", "KB", "MB", "GB", "TB")
    For i = 0 to 4
    If iSize > 1024 Then iSize = iSize / 1024 Else Exit For End If
    Next
    FormatSize = Round(iSize, 2) & " " & aLabel(i)
    End Function
    Sub ShowError(strLocation, strMessage)
    If blnShowErrors Then
    WScript.StdErr.WriteLine "==> ERROR at [" & strLocation & "]"
    WScript.StdErr.WriteLine " Number:[" & Err.Number & "], Source:[" & Err.Source & "], Desc:[" & Err.Description & "]"
    WScript.StdErr.WriteLine " " & strMessage
    Err.Clear
    End If
    End Sub
    The only part pending, is to achieve this for the 'My Documents' folder within each User Profile folder.
    Is this possible?
    Please help.

    Here are a bunch of scripts to get folder size under all circumstances.  Take your pick.
    https://gallery.technet.microsoft.com/scriptcenter/site/search?query=get%20folder%20size&f%5B0%5D.Value=get%20folder%20size&f%5B0%5D.Type=SearchText&ac=2
    ¯\_(ツ)_/¯

  • Determine Data Size of InfoObject

    Hi,  InfoObject maintenance allows you to specify the data class size of the infoObject. 
    Example:  3 = < 25meg
              4 = > 160 Meg
    Does anyone know how to determine this size?  Is it determined by one specific table or a combination of the the various master data tables?
    Any opinions or experiences are greatly appreciated!

    The procedure is as follows (assuming the backend is Oracle):
    Check the data class in the infoobject (Extras --> Maintain Db storage parameters --> note the data class).
    Check the tablespace assigned to the data class (SE16 TAORA --> note the tablespace)
    Go to DB02 transaction --> Click on the current sizes --> double click on the tablespace --> in object name give the <infoobject name without 0 in case of std delivered> eg: for 0PROFIT_CTR give PROFIT_CTR
    This should give you a list of all the tables and indices with the current sizes. you can also check the growth over a period of time.
    The above procedure should work in most of the cases except the cases where the infoobject refers to different table for text (say for example 0FISCPER refers to T009C for text)
    If the Data class is not populated the you need to find the tablespace by hit and trial method (though usually the tablespace would be PSAPDW2 I think!!)
    Hope this helps
    Thanks,
    Gopal

  • Got "java.lang.OutOfMemoryError: allocLargeObjectOrArray - Object size" Err

    System :jrockit-R27.4.0-jdk1.5.0_12
    4 GB RAM
    3GB Switch
    JVM Setting:
    <java classname="com.nomis.documentmgmt.scenario.OptBuildBaselineScript" fork="yes" failonerror="true" maxmemory="1536m">
    <jvmarg value="-client"/>
    <jvmarg value="-Djava.library.path=${dist.dir}/auxiliary/lib"/>
         <!--jvmarg value="-Xms128m"/-->
    <jvmarg value="-Xms1536m"/>
    <jvmarg value="–Xmx1536m"/>
    <jvmarg value="-XXcompactratio=100"/>
    <jvmarg value="-Xgc:genpar"/>
    <jvmarg value="-Xns:96m"/>
    <jvmarg value="-XXlargeObjectLimit:8192"/>
    <jvmarg value="-XXtlasize:16384"/>
    <jvmarg value="-XXgctrigger=5"/>
    Got Below error message
    [java] Exception in thread "Main Thread" java.lang.OutOfMemoryError: allocLargeObjectOrArray - Object size: 1333880, Num elements: 333465

    Looks like you are running out of memory allocating a large array.
    -- Henrik

  • Oracle DBSL -  Determine / Define size of fetch array

    Hello guys,
    i have a question about the Oracle DBSL and how it determines the size of the fetch array.
    I am refering to the following documents / documentations:
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/86a0b490-0201-0010-9cba-fd5c804b99a1
    Quote:
    As long as you do not program an UP TO ROWS in ABAP, the database gets as many table rows as possible per communication set (as many as fit in 32k).
    http://help.sap.com/saphelp_nw04/helpdata/en/d1/801f96454211d189710000e8322d00/frameset.htm
    Quote:
    You have to specify the size of an array before runtime. However, because you cannot know the size of the dataset the system will return, you must define a very large array to avoid an overflow.
    To circumvent this problem, the SAP Basis System translates ABAP Open SQL statements into Embedded SQL. To do this, the system defines a cursor.
    Ok but the translated embedded SQL code has also to specifiy an array fetch size (how many rows are retrieved by one fetch).
    Is this a profile parameter or is it really calculated (how many rows of a specified table would fit into 32k) dynamically in the DBSL?
    Regards
    Stefan

    Hello Michael,
    i am refering to the documentation of DEFAULT_SDU_SIZE:
    > Use the parameter DEFAULT_SDU_SIZE to specify the session data unit (SDU) size, in bytes to connections.
    > session data unit (SDU)
    >A buffer that Oracle Net uses to place data before transmitting it across the network. Oracle Net sends the data in the buffer either when requested or when it is full.
    Ok, that controls the transmit moment in the network layer.. but not the number of rows which are returned by a single FETCH call (through the OCI). (For example in sqlplus it can be set with set arraysize XX)
    I have tested also a little bit around with different sap standard tables in an ERP 2005 system.
    I have activated a SQL Trace (ST05) and done a "select * from <TAB>" via SE16 (no count limit!).
    In my tests there were fetched different number of rows -  take a look by your own:
    Time  Object    Operation  Rows   Returncode
    2.451 T100       FETCH     321      0
    1.915 T100       FETCH     321      0
    1.912 T100       FETCH     321   1406
    1.246 E071K      FETCH     109      0
    1.218 E071K      FETCH     109      0
    1.155 E071K      FETCH     109      0
    T100 (4 VARCHAR columns)
    E071K (14 columns of different types)
    So it seems like the DBSL dynamically calculates the number of rows which can be returned by a single fetch call based on the row size (number of columns and column sizes) and other unknown factors.
    If this is true, it would be really great and nothing have to be done by us (the customers!).
    But if the DBSL dynamically calculates the max. number of rows per fetch:
    Why is a "SELECT * FROM <TAB> INTO <ITAB>" preferred - the SELECT Statement in a LOOP (like in the example) is also fetching the max number of rows by each fetch, or?
    The example: http://sap.mis.cmich.edu/sap-abap/abap04/sld017.htm
    That was only a notice on some small tests, which i have done.. maybe someone knows it in detail.
    Regards
    Stefan

  • Is it right to mix sizes of memory modules in a mac mini 2012? for example 2Gb 8Gb?

    Is it right to mix sizes of memory modules in a mac mini 2012? for example 2Gb 8Gb?

    Welcome to the Apple Support Communities
    You can do that without any problem, always that the total amount of memory is less than the maximum memory your Mac mini supports. A Late 2012 Mac mini supports 16 GB of memory, and you can find in this site the steps to install more memory > http://support.apple.com/kb/HT4432?viewlocale=en_US&locale=en_US#1

  • How to determine the size of an InputStream??

    Hello,
    I need to get the size of an inputstream. In fact, I am working with java.nio.channels and need to tranfer a file from within a Jar to the FileSystem.
    I have created a ReadableByteChannel from the jar resource, and a FileChannel from the FileSystem destination. The problem is that to use the FileChannel .tranferFrom(..) I need the size of the src file. But, ReadableByteChannel has no size() method.
    How can I determine the size of this InputStream??
    advanced Thanx
    here is code:
    private void copyResourcesToFileSystem(){
              try{
                        String name = getFileName(); // gets the name
                        ReadableByteChannel srcChannel =
                             Channels.newChannel(this.getClass().getClassLoader().getResourceAsStream(("dtd/"+name)));
                        File newFile = new File(TempDirCreator.getXmlDir(),name);
                        FileChannel dstChannel = new FileOutputStream(newFile).getChannel();
                        dstChannel.transferFrom(srcChannel, 0, srcChannel.size());  // doesn't work -- there is no ReadableBC.size()
                        // lets close the show
                        srcChannel.close();
                        dstChannel.close();
              }catch(IOException x){x.printStackTrace();}
              catch(Exception ex){ex.printStackTrace();}
         }

    In general the "size of an InputStream" is a meaningless concept. It's possible to have an InputStream that never terminates. So if you can't get a size from whatever you're reading from, you're out of luck.
    I missed where you explained why you need the size. I've never felt the need to know how many bytes would be passing through my code when copying from input to output.

  • How to determine the size (in pixels) of the current mode

    Hello.
    I am looking for a was to determine the size (horizontal and vertical pixels) of the current mode (SAPGUI window). I have already looked through the methods provided by class CL_GUI_CFW...
    CL_GUI_CFW=>GET_METRIC_FACTORS provides the size of you display (i.e. 1600 x 1200 pixels) and some other information I am not able to interprete.
    Futhermore I have had a look at the Methods CL_GUI_CFW=>COMPUTEPIXEL, but I don´t know how to use them.
    Has anybody of you any experiences in this topic? I would be grateful ...
    MIKE

    Sorry Manoj,
    but i didn´t find out, why these programs should be able to solve my issue. They just display a picture using the CL_GUI_PICTURE control.
    I am looking fo a way to resize a given control to the very maximum, so that it fills the whole SAPGUI window!
    Thanks anyway...
    MIKE

  • Determining the size of an Image

    I am running Pages 5.2 and I have a document with a whole load of images taken from photos. Usually I shrink the original images to keep the document size manageable but I forgot on some but I don't know which. Is there a way I can determine the size of individual images in the document ?

    In Pages v5.2, there does not appear any means to assess the image storage size, but File > Reduce File Size will offer a prompt stating an amount it can reduce the current selected image.
    Another approach is to select the image, and press command+C to put it on the clipboard. Launch Preview, ignore the open dialog, and choose File > New from Clipboard. You now have two choices to assess image size: 1) Use the Inspector (General Info panel) from the toolbar, or 2) Menu > Tools > Adjust Size...

  • How do I determine the size of an event (cmd I does not show any size for events).

    How do I determine the size of an Event in iPhoto? (Cmd + I does not show size information at the event level).

    If you're running iPhoto 8 (09) select the event and look at the Info pane at the lower left hand corner of the window.  It will give you the number of photos and size:
    for iPhoto 9 (11) open the Event, select all of the photos in it and open the Info drawer at the right by typing Command+i.  The number of photos and size will be at the top of the Info drawer.
    OT

  • How do you determine what size tablet to get (storage wise)?

    I looking to get a table (either the IPad or the Asus Transformer Primer.  I'm thinking of using it mostly for travel and would like to use it for internet connections, email and downloading & watching movies & music.  How can I figure out how much storage (16gb, 32gb, or 64gb) I'm going to need?
    Thanks!

    I determined what size of tablet I got (storage wise) based on two things: 1) Price and 2) Whether or not I could easily expand the storage.
    For starters, you are going to get the most bang for your buck from the Prime. The 32GB Prime costs the same as a 16GB iPad. So right there you have twice the storage for the same price.
    If you happen to fill up the 32GB of internal storage (which is not that hard since you pan on loading the thing up with movies and music) you can simply get a 32GB micro sd card for 40$ and double your space (this is not even an option with the iPad). Also, you could add even more space via the SD card slot or the USB port on the keyboard dock.
    With the iPad, once you fill the thing up, you are done. From that point on you have to manually move music and movies off the device in order to add new stuff. I used to have to do this with my old iPod touch and it was quite a tedious and annoying thing to have to do. Of course I only had 8GB to work with back then.

  • How do I determine array size in a formula node

    I am feeding an array into a formula node to perform an operation on. However the size of the array can be an arbitrary size. How can I determine its size to use for iterating through a for loop?
    I suppose that I could add another input that is fed with the array size from the array palate but I would like to know if it can be done inside the formula node itself.

    Your own advice is the only and best one.
    greetings from the Netherlands

Maybe you are looking for

  • Having a problem with image IO and drawing image

    My question did not come out on the other posting. I am getting them image from a JPanel. I then convert the image into a renderedimage. Use the ImageIO.write method to convert to png format. I don't want to save the image on the local disk so it is

  • Since using cloudflare for my site I'm having troubles with Firefox cache

    Hello, Since I'm using CloudFlare for my Site I'm having a weird trouble occurring only with Firefox (version 16.0.2 / Mac OsX.6.8), but not with Chrome or Safari. When I navigate from the main page of my Wordpress Site to a single post, then back to

  • Parallel execution of same program with different parameters.

    Is it possible to start the same plsql routine parellelly from PLSQL. Begin prog1 1 1000 prog1 1001 2000 prog1 2001 3000 End; I mean to say something like in Unix where in you can prog1 1 1000 & prog1 1001 2000 & prog1 2001 3000 & Thanks.

  • LR5 Export to Nik HDR Efex Pro 2

    Win 7, 64 bit, LR5.2RC, Nik HDR Efe Pro 2.... From Export > HDR Efex Pro 2 it used to pause at a screen providing three choices (from memory), "as copy with LR adjustments", "as copy without LR adjustments" or "as orignal".  Now it skips that screen

  • Bank statement - Deleted automatically

    Hi All, When we executed FF67,& selected overview button, selected co.code which the bank statment was deleted. we double click the co.code, status shows Elec:deletion ID set. we executed FEBA the date which statment was delted, getting blank. Please