I want to know Size of operator in java like cpp

H

Hendrik Maryns

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Srinu schreef:
how do we know how much mewmory allocated to class

Google is you friend.
H.
- --
Hendrik Maryns
http://tcl.sfs.uni-tuebingen.de/~hendrik/
==================
http://aouw.org
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)

iD8DBQFFF4yoe+7xMGD3itQRAuUgAJ9CkZUKJ5ffDhFgBu/3F0VNpmH5OwCdEyuV
iBd9vDyB6YY1VyA/MNVCxv4=
=twjy
-----END PGP SIGNATURE-----
 
M

Mark Jeffcoat

Srinu said:
how do we know how much mewmory allocated to class

Java doesn't need a sizeof operator, because it doesn't
have C's platform-dependence in the size of various
types.

Don't try to roll your own profiler. There are plenty
of good ones available, even for free; I'm using JRat
(jrat.sourceforge.net) myself.
 
M

maas

and you just can't rely on the results you get using any 'indirect
approach' (as the freeMemory one, posted above)... the underlying
implementation can change even among different JRE/SDK versions...

but there are some 'rules of the thumb' for using memory wisely:

.. byte, short and int are at most as big as an 'int', and a int
occupies at least 4 bytes
.. a char occupies at least two bytes
.. an object is as big as the sum of its componets
.. an array is an object too

and etc.

but there's no way to precisely define the space used by your data
structures, you can not get to know the size of the data structures
maintained by the garbage collector and by the virtual machine...

maas

-
http://www.marcosaurelio.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top