modify get_memory_size method