<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def heap_snapshot(self):
 """ Return heap snapshot """


        self.lock.acquire()
        res = self.ext.mr_heap_snapshot(self.ctx)
        self.lock.release()

        python_value = res.contents.to_python()
        self.free(res)
        return python_value