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

Similar Messages

  • 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 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
    ¯\_(ツ)_/¯

  • 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 I determine the size of my iTunes library

    How do I determine the size of my iTunes library?

    In Music view, you will see the song count, size, and total playing time in the Status Bar at the bottom. 
    If the Status Bar is not present, enable it either via View > Show Status Bar, or by holding the CTRL key while you press the / key.

  • 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 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

  • How do I determine the size of my photo library

    I want to know the size of my photo file so that I can determine how much space I need to store them in iCloud (iPhoto version 9.6)  Os Version 10.10.2
    Thanks
    Dan

    Depends on what you mean and... you can't store an iPhoto Library in the Cloud.
    If you use the size determination in the iPhoto Window, that reports the approximate size if you export everything at the 'Current Setting' (which you would not want to do. See below*)
    If you check the size of the package in the Finder (Pictures / iPhoto Library) that reports the disk space used for the combined size of the Masters, Previews, Thumbnails, Caches, Database and metadata files.
    Though, as I say, it's not really an issue as you can't put an iPhoto Library in the Cloud.
    *This User Tip
    https://discussions.apple.com/docs/DOC-4921
    has details of the options in the Export dialogue.

  • How do I determine the size of an event queue?

    Hi,
    I'd like to be able to programmatically determine how many events are in queue so that I can change how they are processed based on how far behind the loop is.
    Is there a way to easily do this in labview? 
    I suppose I could create an identical parallel event loop that just counts the events as they come in, and then subtract the ones that get processed by the main event loop, but it seems like there should be an easier way.
    I'm using LV 8.1
    Thanks,
    Greg

    So you are recomending running two event loops, one waiting for the faster events and one waiting for the slower events?
    I wouldn't put it that way.
    Any event that takes 'long' (eg. a significant amount of time), should be processed in a consumer loop.
    So the event arives in the normal event structure, and is than feed to a consumer loop via a queue.
    In the LabVIEW examples there is a framework example called 'Produces/consumer with events' (or something like that).
    If you have a specific type of event generating very fast and you are only interested in the last a notifier might be usefull.
    Ton
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep www.lvug.nl
    My LabVIEW Ideas
    LabVIEW, programming like it should be!

  • How do you determine the size of a table in mb

    Hi,
    I have a table which holds a number of pdf docs - I need to find out how large the table is in mb
    How do you do it - is there an sql command ?
    Thanks in anticicpation
    SD.

    Many thanks ............
    select sum(bytes)/1024/1024
    from user_segments
    where segment_name in (select segment_name from user_lobs
    where table_name = 'SUPPORTING_DOCUMENT')
    or segment_name = 'SUPPORTING_DOCUMENT'
    This sql does the trick and tallies with some rather manual calcuations I have done in sql sum(doc_size) on the docs table.
    As a newbie please could you explain segments ?
    Thanks in anticpation
    SD.

  • How do I determine the size of an image ( bytes not dimensions )?

    I am working on an application which downloads images from the web and caches them for speed reasons. I want to allow the users to browse the cache and dump selected images to free up memory. Ideally I would display the image size in bytes for each cache entry, but I haven't seen any way to access this info.
    I do not want dimensions. getIconHeight() * getIconWidth() doesn't address bit depth at all, which can make a huge difference. If there was some getBytes() method I could use that, but I haven't found one yet.
    Help?

    Only if you use a stream and count the bytes. I'm loading it like this:
    ImageIcon foo = new ImageIcon( new URL( "http://foo/bar/baz.gif" ) );

  • 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.

  • 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 of an iMovie09 project?

    Hello:
    I recently created a nice video of about 2 hours in iMovie09. I "shared" it to iDVD but it was about 10% too big to burn. I went back to iMovie09 and removed some time to make the project smaller but how can I determine the size of my iMovie09 projects before I send them to iDVD? I know that both time and audio will affect the size of the iMovie09 project so the time of the video is not necessarily an accurate indicator.
    Thanks!

    Welcome to iMovie Discussions.
    As long as your movie is under about 1hr 50 minutes it should fit on a DVD.
    The thing which determines how much time is available on your DVD is usually the complexity of any Menus which you add in iDVD.
    With a simple Menu, which may "eat up" 10 mins of space, you should have room for 1h 50mins of movie.
    With complex, multi-level menus, your movie running time may be reduced by about 25 mins, or possibly more.
    Keep menus simple, and you should have space for about 1hr 50mins. It's always running time which counts, NOT "size" (in GB) of your movie.

  • How do you determine the optimal size for Mozilla Firefox?

    How do you determine the optimal size for cache in Mozilla
    Firefox? I am using Firefox 7.0.1 on a 64-bit Windows 7 Ultimate operating system with 3GB RAM and 300 GB hard drive, but I have other computers running Windows XP. If the answer doesn't apply to all current versions of Firefox on all supported Windows operating systems, please explain the differences. Is there a formula for calculating the best cache size?

    I found that the best idea is to let Firefox decide that itself.

Maybe you are looking for

  • Nouveau PDISP errors when attempting to boot into installation media

    I'm attempting to install Arch onto my laptop, and I am unable to get the Arch media to even boot at all. It's an MSI GT60-2OC, so it has UEFI, as well as an NVIDIA 770M, with Optimus. Here's an example of the errors I'm seeing. They get spammed all

  • How to Start With

    hi all, I am a java developer, i came across FB and FDS through my Friend, and soon, got addicted for the latest RIA development tools. I downloaded the Latest Trial of both FB and FDS and try to start things...but, i got stuck up at the initial conf

  • Microsoft Wireless Presenter 8000 mouse and Toshiba Bluetooth Stack

    Some of the specific functionalities of this MS Bluetooth Mouse do not work with the latest Toshiba Bluetooth Stack : magnifier, digital ink... The other functions of this mouse (and the remote controller functions too) work perfectly. The magnifier,

  • Re: ALV OUTPUT

    Dear Experts,         I have a report which is displaying 2 types of reports( based on the selection of radio button in selection screen assembly report, production report) both are having same fields and different fieldcatalogs Now, My requirement i

  • Asset upload: Deactivation Date not available in the standard program(LSMW)

    Hi, I am trying to use the standard program for Assets upload,RAALTD01. But, the field de-activation date (ANLA-DEAKT) is not available for mapping. This is the only field am missing out of more than 200 fields involved in the upload. What would be t