?
Solved

Object's size

Posted on 2003-03-02
2
Medium Priority
?
228 Views
Last Modified: 2010-03-31
How can I measure an object's size, in terms of memory?

I have this method, getting me stuff(1D or 2D arrays usually), and I want to check their size before I serialize them and tx them over a network.

0
Comment
Question by:piou
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 92

Accepted Solution

by:
objects earned 400 total points
ID: 8054924
you can't. And the size in memory != the serialized size anyway.

To check the serialized size before transmitting you could serialize to a buffer using ByteArrayOutputStream, and check the size of the buffer.
0
 

Author Comment

by:piou
ID: 8054962
Thanks! The byte array stream does it okay.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This video teaches viewers about errors in exception handling.
Suggested Courses
Course of the Month11 days, 7 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question