Adding member variables to a class certainly boosts the memory footprint of its instances on the heap, but what about a class’s methods?
For example, if I have a class composed of a single StringBuilder, but keep adding dozens of methods to manipulate that StringBuilder, will each instance of that class take up proportionally more memory as I add more methods?
Thanks!
No, adding methods does not increase the footprint of the object, only the footprint of the compiled code. In other words, the per-instance memory cost is zero.