Size of Serliazed objects

Hi,
Is there anyway to measure the size of the Serliazed objects (in bytes) used in RMI?
Any help is appriciated.
Many thanks in advance

Not through RMI but you can measure the seze of an object using a simple trick like this.
class FakeOutputStream extends OutputStream{
   long count = 0;
   public void close() throws IOException{
      //does nothing;
   public void flush() throws IOException{
      //does nothing;
   // write method keeps a count of the invocations
   public synchronized void write(int b){     
      count++;
   public synchronized long getCount(){
      return count;
class SerializableClass implements java.io.Serializable{
    //Blah
    //Blah
//You main will look like this
FakeOutputStream  fake = new FakeOutputStream ();
ObjectOutputStream oos = new ObjectOutputStream (fake);
oos.flush();
//Since the object streams dump some header data to stream you will need to
//get that length and substract it from the final length
long oldCount = fake.getCount();
//Write the object
oos.writeObject(new SerializableClass());
oos.flush();
oos.close();
//Print the size
System.out.println(fake.getCount() - oldCount);

Similar Messages

  • # of objects, not the size of the objects, determine size of a Collection

    There are objects, and references to objects.
    Do, List / Set / Map , etc. just maintain a list of 32-bit addresses for their contained objects? What more does a Collection need, memory-wise, to add an element? The size of the objects in a Collection should not matter?
    listA.add(new Integer(2));  // listA size grows by 32-bits
    listB.add(new GiantSizedClass());  // listB size grows by 32-bitsI started thinking about Collections being able to dynamically grow in runtime. I heard this is complex, but it "looks" like all you do is append a memory address and incriment a counter? This sounds quick, easy, and incorrect. I don't understand. Thanks.

    jverd, ejp: you have always been there with quick responses to help me. ejp, i purchased your book "Fundamental Networking in Java". When I start programming again, your book about RMI is on my list. that said.
    with all sincerity. i belived that serliazing objects in byte[] allows for storing objects in objects, not object references in objects. here is my test code (just cut/paste):
    My idea seems similars to me as cryogenics and so that is the theme of my test code (and it is my favourite movie). note: this code is "proof of concept" and is exetremely hacked together.
    public class Test {
      private static HashMap<String, byte[]> barracks = new HashMap<String, byte[]>();
      public static void main(String[] args) {
        try {  new Test().go();  }   catch(Exception e) {  e.printStackTrace();  }
      public void go() throws Exception {
        Employee empl = new Employee("Dallas", "Captain");
        barracks.put(empl.name, cryogenicallyFreeze(empl));
        empl = new Employee("Kane", "Navigator");
        barracks.put(empl.name, cryogenicallyFreeze(empl));
        empl = new Employee("Ripley", "First Officer");
        barracks.put(empl.name, cryogenicallyFreeze(empl));
        empl = new Employee("Ash", "Science Officer");
        barracks.put(empl.name, cryogenicallyFreeze(empl));
        System.out.println("___log file___");System.out.println(".........");
        int id = (int) (System.currentTimeMillis() % barracks.size());
        System.out.println("[Nostromo]: emergency id #"+id+". Re-animation initiated...");
        switch (id) {
          case 0: empl = (Employee) reanimate("Dallas"); break;
          case 1: empl = (Employee) reanimate("Kane"); break;
          case 2: empl = (Employee) reanimate("Ash"); break;
          case 3: empl = (Employee) reanimate("Ripley");
        System.out.println("[Nostromo]: \"" + empl.name + "\" in command.");
        System.out.println("["+empl.name+"]: Hello. I was an object, not a reference, stored in a collection.");
        System.out.println();
        public static Employee reanimate(String name) throws Exception {
            PipedOutputStream pout = new PipedOutputStream();
            PipedInputStream pin = new PipedInputStream(pout);
            byte[] frozenEmpl = (byte[]) barracks.get(name);
            pout.write(frozenEmpl);
            ObjectInputStream ois = new ObjectInputStream(pin);
            return ((Employee) ois.readObject());
        public static byte[] cryogenicallyFreeze(Employee emp) throws Exception {
            PipedOutputStream pout = new PipedOutputStream();
            PipedInputStream pin = new PipedInputStream(pout);
            ObjectOutputStream oos = new ObjectOutputStream(pout);
            oos.writeObject(emp);
            byte[] frozenEmpl = new byte[pin.available()];
            pin.read(frozenEmpl);
            return frozenEmpl;
          public static class Employee implements Serializable {
            String name; String title;
            Employee(String n, String t) {  name = n; title = t;  }
    }"inside" of each byte[] object is an "Employee" object? I can't see it any other way. But I am not the sharpest pencil in the drawer...I'm on vacation from coding for a while. maybe i will get it when i start again. thanks.
    Edited by: rdkh on Jan 29, 2010 3:53 AM

  • How to change the size of every object in a flash file

    i created a flash website but the problem is the size is to large to fit on screen i have imbeded buttons, Movies clips, masks, and about 7 different scenes in this 13 mb movie what do i do to make the physicle size of the objects on screen so i can view it on my sceen?

    the easiest thing to do would be to load your swf into a main swf and resize the target movieclip (as2) or loader (as3) after loading is complete.

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

  • 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 to measure the size of an object written by myself?

    Hi all,
    I'm going to measure the performance on throughput of an ad hoc wireless network that is set up for my project. I wrote a java class that represents a particular data. In order to calculate the throughput, I'm going to send this data objects from one node to another one in the network for a certain time. But I've got a problem with it- How to measure the size of an object that was written by myself in byte or bit in Java? Please help me with it. Thank you very much.

    LindaL22 wrote:
    wrote a java class that represents a particular data. In order to calculate the throughput, I'm going to send this data "a data" doesn't exist. So there's nothing to measure.
    objects from one node to another one in the network for a certain time. But I've got a problem with it- How to measure the size of an object that was written by myself in byte or bit in Java? Not.

  • Size of serialized Objects

    Hello everybody,
    When I serialize a object to a Byte Array the size of the Byte Array is not exactly the size of the object because of some meta data information. Is there any way there I can predict excatly the size that the Object will have when I serialize it? Of course I known the attributes size of this Object.
    For example if I have an Object X with two attributes Integer A and B with 4 bytes each, I'd like to predict that the Byte Array of this serialized Object wil have 10 bytes (8 for the two attributes and 2 for meta data). Does anybody have an idea?
    Thanks,
    Bruno

    Is
    there any way there I can predict excatly the size
    that the Object will have when I serialize it?Yes. You can serialize it to a byte array, then take the size of that. Then you can send the byte array instead of serializing the original object.
    Basically this is something that's very unlikely to be useful. What are you trying to achieve and why do you think you need to know this information?
    Dave.

  • Size of user objects

    Hi *,
    I have a question concerning the size of all objects owned by a user. I tried to figure this out with several methods:
    1. rman: one fullbackup ca. 64 GB
    2. size of datafiles - free space: 35 GB
    3. export: 15 GB
    Why do I get these big differences?
    regards
    Andreas

    Export extracts only rows tables and DDL for objects. Indexes "data" are not exported.
    You tablespaces are (hopefully) not full: the free space is likely not backed by by rman.
    Message was edited by:
    Pierre Forstmann

  • How to stop changing stroke weights when changing the size of an object in CS5 on Windows 7?

    I'm not sure what I did to make this happen or how to change it back, but for some reason when I change the size of an object/line it changes the stroke weight as well. (For example, if I drew an ellipse with stroke weight 2 pt, and then increased the size the stroke weight would be 2.856 pt or some such number instead of 2 pt.) Does anyone know how to change this back?
    Thanks!

    Take a look at the Scale Strokes and effects preference either in the general programme preferences or in the flyout menu of the Transform palette.

  • How to get a size of a object

    Hi
    Anybody Knows how to get a sizeof a object in java,
    Pls reply to this.
    cheers,
    Sen

    That's a bit ambiguous...
    If you are asking about the size of the object reference in memory, then it is defined in the JVM specification.
    I suspect you are asking about how much memory a given object takes up - that's going to be a bit tricky, because objects point to other objects, etc...
    Rather than trying to come up with a solution to the question, I'd like to ask exactly why you need this - that might help the forum to come up with a solution to the real problem. Sound good?
    - K

  • CRM - Modifying block size of Adapter Object (R3AC1)

    Hi,
    We have differences between SAP R/3 and CRM systems. Not all the business parters are in sync between two systems. In order to bring business parter tables in sync, we are executing R3AR2/R3AR4 for a range of 10,000 BPs at a time.
    My question is, we are doing this by with the block size of adapter object BUPA_MAIN to 1.  This is resulting into creation of 1 queue per business parter. Is there any harm with keeping the block size to 1 ?
    We attempted to do it with block size 100 but for some reason, it's not working fine. With block size 100, not all the BPs from input range are getting selected for replication.
    Thanks,
    Amol

    Hi Amol - For the MATERIAL ADAPTER we are using MARA-MTART criteria, but also want to apply MARC-WERKS.
    In order to stop the entire MATERIAL record from being downloaded, we used BTE OPEN_FI_PERFORM_CRM0_200_P and wrote a function module to interrogate the MARC table for the MATNR.
    If the MATNR was not extended to a specific PLANT, then the record was not downloaded to CRM.
    However, I discovered that with the MATERIAL BLKSIZE = 100, there were some records that did not meet the criteria slipping through to CRM.
    So I made the BLKSIZE = 1, and the correct filtering is occurring!  I'm not sure why, but I suspect there is something in the CRS_SEND_TO_SERVER function module in ECC, that is not looping properly.  And it works just fine when there is just one record at a time.

  • The Control Panel (top bar) no longer shows the location or size of an object when I select an object using the black arrow.

    I'm only able to see/adjust the location or size of the object by opening the Transform panel. 
    This is what I used to see:
    Now my Control panel looks like this where the above information used to be when an object was selected using the black arrow:

    tracyelaine,
    It may be time for the list (you may skip 5) in this case).
    The following is a general list of things you may try when the issue is not in a specific file, and when it is not caused by issues with opening a file from external media, see below. You may have tried/done some of them already; 1) and 2) are the easy ones for temporary strangenesses, and 3) and 4) are specifically aimed at possibly corrupt preferences); 5) is a list in itself, and 6) is the last resort.
    If possible/applicable, you should save current artwork first, of course.
    1) Close down Illy and open again;
    2) Restart the computer (you may do that up to at least 5 times);
    3) Close down Illy and press Ctrl+Alt+Shift/Cmd+Option+Shift during startup (easy but irreversible);
    4) Move the folder (follow the link with that name) with Illy closed (more tedious but also more thorough and reversible);
    5) Look through and try out the relevant among the Other options (follow the link with that name, Item 7) is a list of usual suspects among other applications that may disturb and confuse Illy, Item 15) applies to CC, CS6, and maybe CS5);
    Even more seriously, you may:
    6) Uninstall, run the Cleaner Tool (if you have CS3/CS4/CS5/CS6/CC), and reinstall.
    http://www.adobe.com/support/contact/cscleanertool.html
    External media: It is always recommended here to open/save from/to own hard disk, and to copy from/to networks and removable media. You may be lucky (for a while), but the chances of file corruption and other unpleasantnesses are immensely greater when you use anything but the harddisk, and it is better to be safe than sorry.
    In addition to the (far greater) risk of file corruption, some issues are mentioned here:
    http://helpx.adobe.com/illustrator/kb/illustrator-support-networks-removable-media.html

  • Average Size of an object stored in the cache

    Hi,
    I am trying to query coherence and get the data in to my client. I am using Jconsole to monitor coherence. Is there a way I can find the average size of the object stored in the cache in bytes, so that I can determine how many bytes are sent over the network from coherence back to my client?
    -Regards,
    Mayuresh

    If you are using binary unit calculator, you can get object size information from MBean.
    You should check cache MBean on back tier. "Size" attribute is number of entries in this instance of backing map and "Units" attribute would be size in bytes (but only if binary unit calculator is configured).
    Alternatively, if you interested in traffic, you could check extend proxy service MBean in "ConnectionManager" group. It has "TotalBytesSent" and "TotalBytesReceived" attributes.

  • How get size of grafical object?

    I load object from *.wrl using loader. I want get size of this object. How do it???

    Hello,
    The method I use is the following:
    - Find all Shape3D objects within your loaded scene.
    - For each Shape3D object extract it's bounds with:
    BoundingSphere bSphere = (BoundingSphere)Shape3D.getBounds() ;
    - Extract the bounds radius with:
    bSphere.getRadius() ;
    You can also do this with a BoundingBox for more accuracy.
    Remember, though, that the "size" is completely arbitrary, unless you know the measurements and scaling used in the original scene.
    Hope this helps,
    Shawn

  • Getting size of ResultSet Object

    Is there any effective way to retrieve the size of ResultSet object while the type of the ResultSet itself is a default one (TYPE_FORWARD_ONLY) ?

    Maybe I was a little harsh ...or lazy to type anything. I don't think there are any efficient ways to count the number of rows in a ResultSet(for scrollable, forward only, etc)
    You could do the following:
    rs= statement.executeQuery("select count(column1) from table1 where column1<100");
    rs.next();
    long recordCount = rs.getLong(1);
    before executing your real query
    rs = statement.executeQuery("select column1 from table1 where column1<100");
    while rs.next.....
    Jamie

Maybe you are looking for

  • HT4889 Time machine migration issues.

    I migrated info from my old mac to my new mac via time machine.  It took about 5 hours to move all of my files, but since then the "thank you, your mac is set up" screen has been on for over 10 hours.  The wheel has been spinning the WHOLE time.  Wha

  • How do you put videos on the new itunes

    hi can anyone give me a an overview on how to put your vidos on to itunes, many thanks james

  • JDBC, SQL*Net wait interface, performance degradation on 10g vs. 9i

    Hi All, I came across performance issue that I think results from mis-configuration of something between Oracle and JDBC. The logic of my system executes 12 threads in java. Each thread performs simple 'select a,b,c...f from table_xyz' on different t

  • When does an app uses my data package

    when downloading an app, how do i know if it is using my data pakcage when i run the app? for example, i have an alarm clock app does it use my data package every time i set an alarm? will it tell me in the description of the app, and if so what will

  • What do I need to do to get a serial number???

    I bought the student version when I got my IMAC. I've sent my proof, got the notice from www.identit-e.com that "Your eligibility has been verified." and that the serial number has been sent to "the email address you provided."  I have yet to receive