Results 1 to 6 of 6
  1. #1
    devaru2003 is offline Member
    Join Date
    Mar 2010
    Posts
    6
    Rep Power
    0

    Question Runtime overhead of Class inheritence level?

    What is the runtime overhead of class inheritance level.
    what can be the implication of depth of 10 to 20 level deep inheritance.
    Is there any performance hit with such deep level of inheritance.
    Please adivice.

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,018
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by devaru2003 View Post
    What is the runtime overhead of class inheritance level.
    what can be the implication of depth of 10 to 20 level deep inheritance.
    Is there any performance hit with such deep level of inheritance.
    Please adivice.
    The depth of the inheritance tree doesn't matter because when a class is loaded its parent class is already loaded and that one is the only class needed to set up a "virtual function table". i.e. a copy of that table is made and the overrriding method addresses are filled in.

    kind regards,

    Jos

  3. #3
    devaru2003 is offline Member
    Join Date
    Mar 2010
    Posts
    6
    Rep Power
    0

    Default

    Thanks Jos for Quick response
    What I am wondering is as I keep on adding each new level of hierarchy, the overhead is constant or it is increasing per level of inheritance

  4. #4
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,018
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by devaru2003 View Post
    Thanks Jos for Quick response
    What I am wondering is as I keep on adding each new level of hierarchy, the overhead is constant or it is increasing per level of inheritance
    As I wrote in my previous reply: the depth of the inheritance tree doesn't matter. Just more classes need to be loaded if you want to load a deeply nested (inheritane wise) class. The loading per class doesn't slow down when the depth of the class increases.

    kind regards,

    Jos

  5. #5
    devaru2003 is offline Member
    Join Date
    Mar 2010
    Posts
    6
    Rep Power
    0

    Thumbs up tHANKS jOS

    This is really helpful

  6. #6
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    8

    Default

    Instantiating instances of the classes will be affected though, depending on what the constructors of those classes do. As long as none of them do anything "exotic" it is negligible (unless you're instantiating millions of them), but just keep in mind that when you instatiate an object a constructor will be executed in every one of those classes in order to facilitate the instantiation.

Similar Threads

  1. Getting log level in Appender class
    By ashu_knw in forum New To Java
    Replies: 0
    Last Post: 05-14-2010, 11:22 AM
  2. how to call higher level super class method?
    By satheeshtech in forum Advanced Java
    Replies: 2
    Last Post: 01-12-2010, 03:11 PM
  3. [SOLVED] Class-level vs Object-level method()
    By mfaizan24 in forum New To Java
    Replies: 7
    Last Post: 06-23-2009, 09:18 AM
  4. Help with Java Robot and Runtime Class
    By Rmond1254 in forum New To Java
    Replies: 1
    Last Post: 02-18-2009, 06:33 AM
  5. Example of RunTime class
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-04-2008, 09:32 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •