R Systems Interview Question

How to overcome memory leak?