There are lots of Q&A's about the size of a Java object, which is quite straightforward to understand. But I'm wondering about the size of a Java class in the PermGen space.
The reason I wonder about this is because I'm writing a code generator, generating a lot of classes. Essentially, I'm generating two classes for every table/view in a database. Now I also want to model foreign key relationships. Instead of maintaining a complex, serialisable object-structure (think about a table having a unique key being referenced by several foreign keys belonging to other tables having other foreign keys, etc), I'd prefer to generate one class per UNIQUE KEY
and one class per FOREIGN KEY
.
Here are my questions:
- How much overhead on the classloader and the PermGen space will I create with this?
- Is there a difference between
public
classes,static
classes andprivate
member classes? - Do you see a better way to generate foreign key information in source code?