Houzz Interview Question

How memory is allocated and usage could be minimized.