Detecting Memory Leaks with Visual C++ CRT Debug Heap
Required Header Includes
To use the CRT debug heap functions, include headers in strict order:
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
The _CRTDBG_MAP_ALLOC macro must be included without fail. Omitting this macro causes the memory leak report to miss critical details, including the source file name and li ...
Posted on Wed, 03 Jun 2026 16:29:41 +0000 by duckula
Understanding Java ArrayList subList() Pitfalls and Safe Usage
Memory Leak Caused by subList
A common mistake with subList() is inadvertently retaining a reference to the original large list, leading to an OutOfMemoryError. Consider this example:
@Slf4j
public class SubListDemo {
public static void subListOOM() {
List<List<Integer>> data = new ArrayList<>();
for (int ...
Posted on Sat, 09 May 2026 05:39:15 +0000 by jstone3503