Why does an array of classes consume ~20% more memory than array of structs?

Viewed 1955

I'm making a 2D platformer game and to represent a level I'm using 2D array of tiles which are classes with fields for position, type and various flags. When I change the class key word in the tile class to struct, a loaded map consumes about 20% less memory.

I don't know about rights and wrongs of this action, I just want to know why the difference in memory consumption.

Edit: numbers are 1038 MB with tiles as classes and 845 MB as structs (without most of game data).

3 Answers
Related