Memory management is an essential component of any application. There are strategies used to deallocate memory such as smart pointers, garbage collectors and reference counting. To minimize the overhead associated with their execution, higher level coding languages tend to implement optimization strategies on their memory deallocation procedures. The goal of this paper is to compare the performance of three memory deallocation strategies: C++'s smart pointer management systems and C# and Java's garbage collectors. To measure their performance, we created two simple applications aimed at testing deep and shallow memory allocations. These applications allocate a total of 100.000 objects on the heap. We reproduced these applications in C++ using both unique_ptr and shared_ptr classes, as well as in C# and Java, for a total of eight applications. C#s garbage collection system consistently outperformed the others due to its optimized procedures of asynchronously deallocating memory.
Henriques, Luís and Bernardino, Jorge, "Performance of Memory Deallocation in C++, C# and Java" (2018). CAPSI 2018 Proceedings. 10.