Anyone can told me,what is memory padding? Or can anyone suggest me any video?
Memory addresses where an object is stored usually need to be a multiple of the sizeof the object. So if an object is 8 bytes long, it needs to be stored at an address that is a multiple of 8 for the object to be accessed efficiently. Some architectures enforce this requirement strictly while others are relaxed. These relaxed architectures however will need multiple operations to access these improperly stored objects.
So suppose you have a struct that has a char and a double, then plain calculation tells us that the size of the struct would be 9. The char being of size 1 can be stored and accessed from any address. But the double can be accessed only if it is stored in an address that is a multiple of 8.
So the compiler automatically adds 7 padding bytes between the char and the double thus making the size of the struct 16 bytes. Now this struct will be stored on 16 byte aligned memory address (the compiler will enforce this for you) and the entire struct as well as the char and double within it can be accessed efficiently albeit at the cost of 7 extra bytes.