i'm still new to OO in general, but i've always held certain beliefs about certain internals when doing it. Methinks it's time to get some clarity.

When an object gets instantiated, does the entire object get bootstrapped into memory? Or just the data? Or maybe some subset of the two?

It doesn't make sense that when you load an object all of the methods that are coded to go with the object get loaded for every instance of the object, but this has been my long-standing belief since that's what seemed to be the case in C++ and Java (where an object is a collection of data and methods).

If this were the case than if i have 1000 objects instantiated on a system, there are 1000 duplicate 'new' methods running around somewhere (ok, almost but not quite duplicate). There would also be 1000 copies of every other method described for the object. Obviously this seems ineffecient and bulky, not to mention a couple other problems. i want a 1000 different data structures, but not the baggage.

First of all please tell me i'm wrong.
Second, what does get kept in memory? How does some of this fit together?
Please feel free to refer me to a written source, i'm just looking for clarification.

jynx


In reply to OO Baggage by jynx

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.