• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

can i find the length of a class in java

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a static class with only instance variables and no functions can i find the length of a class in java.
 
Ranch Hand
Posts: 1246
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
length?? what do u mean by length?
can you post your class here?

[This message has been edited by FEI NG (edited December 03, 2001).]
 
yash bhatnagar
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi i have got a class with only static member variables and no functions i want to find out the exact length of that class can somebody tell me how to do that.
 
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have never heard of the length of a class !
Do you perhaps mean how much memory the class uses ??
 
Ranch Hand
Posts: 388
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
i think you cannot find the size a single class uses in memory with the means of jdk. there is no need for sizeOf operator since all memory is managed by jvm. if you want to know the size of your class in memory, then try use an external analyzer, or use the java -X option of java to find some interesting switches.
k
 
Ranch Hand
Posts: 2379
MySQL Database Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yash, did u mean how many bytes/kbs each object of a class is taking from memory to be run?
If yes, i have no idea! But u can count the variables and their data types and as we know methods are shared in runtime by objects from stack, so we may guess a little bit. Actually i know this is far from a solution .... ...yet any other idea?

------------------
Muhammad Ashikuzzaman (Fahim)
Sun Certified Programmer for the Java� 2 Platform
--When you learn something, learn it by heart!
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hmmmm - I guess you could try to figure it out based on the ClassFile Format.
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try the method presented here too...
http://java.sun.com/docs/books/performance/1st_edition/html/JPRAMFootprint.fm.html#243 68
HIH
------------------
Valentin Crettaz
Sun Certified Programmer for Java 2 Platform
 
reply
    Bookmark Topic Watch Topic
  • New Topic