Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

10
  • 7
    In what language are you thinking that the code is duplicated for each instance? This doesn't happen in Java, C#, C++. Commented Jan 3, 2016 at 4:22
  • 2
    Well, it might happen with some dynamic language in its infancy, or as a side effect of abused reflection. But in general, no, a Byte isn't going to be much larger than the byte it contains. Commented Jan 3, 2016 at 6:37
  • 1
    The only language I know of where you could get this memory-wasting behavior is Javascript, but even then you'd have to completely fail at prototypal OO to do it. What you're supposed to do in JS is put (both static and non-static) methods on the prototype object, so that all objects inheriting from that prototype will share that one function without any duplication. Commented Jan 3, 2016 at 13:27
  • 2
    Have you considered writing a small program that creates thousands of such objects and doing the measurements yourself? Commented Jan 3, 2016 at 13:51
  • 1
    Ins't the answer to every OO related question: Dependency Injection? If you're bothered about the memory overhead you could just design a "saver" object of which you make one instance, that can be injected.... Commented Jan 3, 2016 at 14:28