Class Methods & Memory Use

I've got a project with multiple I/O channels and I'm writing a class to manage each channel. So when implemented, there will be many instances of this class. Other than some channel specific variables, such as Pin number, calibration values and last value received, the bulk of the class contains methods that handle the grunt work of of the I/O process. These methods and functionality do not change from instance to instance, other than the data used by the method (either an argument or a class variable).

When the program is compiled and loaded into the Arduino's memory, does each instance of the class consume the full memory size required for the class? Or is the compiler efficient and the functionality loaded into memory only once so that each additional class instance only uses up enough additional memory to store the class specific data?

In other words, to reduce the memory used by my program, is it okay to leave a lot of functions and methods within the class which will be repeated many times, once for each I/O channel? Or should I move as much of this "generic" function code into a module that exists only once and reduce the size of my I/O class to the minimum possible?

Thanks.

class methods only appear once.
Virtual methods may have additional overhead in the form of POINTERS to the actual methods (in each object), but the method code itself should still only appear once.

Quercus47:
is the compiler efficient and the functionality loaded into memory only once so that each additional class instance only uses up enough additional memory to store the class specific data?

Yes.

What happens behind the scenes is that the compiler turns class methods into regular functions that take one extra parameter - a reference to the class specific data.

Thank you both for a very clear response. That's the answer I was hoping for.

Thank you both for a very clear response. That's the answer I was hoping for.

You could have figured that out by yourself.

Create one instance of your class. Call a method on that instance.

Compile and link the code, and note the amount of code space and SRAM used.

Create a second instance of your class. Call the same method on the second instance.

Compile and link the code, and note the amount of code space and SRAM used.

The difference between the two sets of values shows you have much code space and how much SRAM are used for one additional instance.