Multiple Class Instances and Memory

H

Hal Vaughan

I haven't had to consider memory or questions of speed vs. memory before,
but now I'm trying to plan out several data structures that are at the
heart of an application. Essentially, I need a number of data tables,
imported from a database and put in a format I can easily work with.

For the first time, I've looked closely at the sizes of compiled classes. I
figured everything would be compiled to byte code, so a class without much
in it would be quite small. When I looked at my classes, though, they were
bigger than I thought.

I'm considering using 2 classes, the first is TNTable, which would be the
class for holding a table of data, and the second is TNRow, which would be
a row of data, including flags to mark if a row has been deleted and index
numbers. There would be a large number of instances of these classes in
memory and there would be many cases of TNTable objects that would use a
subset of the same rows another TNTable uses.

Will I have a large amount of overhead for each instance of a class, or is
there an initial overhead for a type of class with other instances using
less memory? How can I guess about how much extra memory using one more
TNRow or TNTable will cost me?

Thanks for any insight into this.

Hal
 
T

Thomas Kellerer

Will I have a large amount of overhead for each instance of a class, or is
there an initial overhead for a type of class with other instances using
less memory? How can I guess about how much extra memory using one more
TNRow or TNTable will cost me?

The byte code for a class will only be loaded once into memory. The
memory that each instance uses is determined by the member variables
that it creates/allocates.

Thomas
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top