Friday, July 4, 2014

Garbage Collection in VS2013 C++11

The garbage collection in VS2013 C++11 is implemented recursively, which can lead to performance issues. The process involves decrementing reference counts while traversing through the objects. This recursive approach continuously adds calls to the stack.

Key Points:

  • Recursive Approach: The garbage collection process in VS2013 C++11 uses recursion, which can cause the stack to grow as the function is called repeatedly.
  • Stack Management: Each thread has its own stack, and in a single-threaded environment, the stack size can seem almost unlimited (as large as available RAM, e.g., 4GB). However, as the data grows, you can run into memory shortages that may cause the program to crash.

What About shared_ptr?

  • The shared_ptr is not the problem. While the garbage collection process is not fully optimized, shared_ptr itself is still a useful tool. The issue lies in the inefficiencies of the garbage collection implementation in VS2013, not in shared_ptr usage.