How to get the size of a primitive/object?

Is there any way I could tell the size of an object/primitive inside of the ram? I may be completely incorrect on how this works. Also, is there any way to tell how much ram is being used by your program?