Home Help Center

any way to know how much bytes used for object serialization?

mathglmathgl Member gelin yanOrganization: RoundTech Research CentreProject: large scale vehicle tracing system
Hi All..

I have a question about the size of object. As we know all objects before being sent to lan need to map to a sequence of bytes, Do you have any way to know how much bytes an object does occupy. I want to know this number for testing purpose....

Comments

  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Hi,

    You can get the size of a request using protocol tracing by setting Ice.Trace.Protocol=1. Another option is to marshal the object into a byte sequence using the Ice streaming API and measure the size of the byte sequence.

    Cheers,
    Benoit.
  • mathglmathgl Member gelin yanOrganization: RoundTech Research CentreProject: large scale vehicle tracing system
    Hi Benoit

    Thanks for your reply. After checking chapter 36.2, i used slice2cs with --stream to generate the .ice file again for serialization purpose. however when i checked the generated file i found a piece of codes like:

    public override void write__(Ice.OutputStream outS__)
    {
    Ice.MarshalException ex = new Ice.MarshalException();
    ex.reason = "type RoundTech::TTianHeInstantMessage was not generated with stream support";
    throw ex;
    }

    Could you please give me a guide how to let a type support stream?

    Thanks.
  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Hi,

    Which Ice version do you use and on which platform? This should work. With Ice 3.4.0, you can try out the C# Ice/invoke demo for an example on how to marshall various Slice structures with the Ice streaming API.

    Cheers,
    Benoit.
  • mathglmathgl Member gelin yanOrganization: RoundTech Research CentreProject: large scale vehicle tracing system
    Hi Benoit.

    Thanks for your reply. It was a typo actually. I use a macro command to invoke slice2cs. adding --stream didn't work at first until i fixed it.

    Now it works. Thanks again..
  • mathglmathgl Member gelin yanOrganization: RoundTech Research CentreProject: large scale vehicle tracing system
    benoit wrote: »
    Hi,

    Which Ice version do you use and on which platform? This should work. With Ice 3.4.0, you can try out the C# Ice/invoke demo for an example on how to marshall various Slice structures with the Ice streaming API.

    Cheers,
    Benoit.

    Hi Benoit

    i want to know another thing about sequence type. In my ice file i have two definitions for sequence<string>. I show the code as follow:

    sequence<string> StringArrayType;

    ["clr:generic:List"]
    sequence<string> StringListType;

    this file works perfect without --stream. When i try to use the generated .cs file which is compiled with --stream. The compiler comlains there are no proper overload methods for StringSeqHelper outputstream/inputstream.

    If i drop down one of them, now it works again with --stream. Do you have any idea about that??

    Thanks..
  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Hi

    I'm afraid you just found a bug in the Ice streaming API :(

    The generated C# code won't compile if it contains custom types such as ["clr:generic:List"] and if it's generated with --stream. We'll fix this, thanks for the report!

    Cheers,
    Benoit.
  • mathglmathgl Member gelin yanOrganization: RoundTech Research CentreProject: large scale vehicle tracing system
    Hi Benoit

    I am using ICE 3.3.2 instead of 3.4, so probably this bug has been fixed....
  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Hi,

    Actually, you're the first one to discover this bug so it isn't fixed in 3.4. It will be fixed in next version. Thanks again for the bug report.

    Cheers,
    Benoit.
Sign In or Register to comment.