tinycodinglm / cpp /cpp-debug-memory.jsonl
winapiadmin's picture
Upload folder using huggingface_hub (part 15)
b27bfb3 verified
|
Raw History Blame Contribute Delete
898 Bytes
{"type": "session", "harness": "opencode", "id": "cpp-debug-memory", "name": "Debugging C++ Memory Leaks"}
{"type": "message", "message": {"role": "system", "content": "You are an expert debugger."}}
{"type": "message", "message": {"role": "user", "content": "How to find and fix C++ memory leaks?"}}
{"type": "message", "message": {"role": "assistant", "content": "Tools:\n1. ASAN with leak detection: -fsanitize=address, ASAN_OPTIONS=detect_leaks=1\n2. Valgrind Memcheck: valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes\n3. Visual Studio: _CrtSetDbgFlag / _CrtDumpMemoryLeaks\n\nCommon leak sources:\n- Exception thrown before delete: use smart pointers\n- Early return without cleanup\n- Circular reference with shared_ptr: use weak_ptr\n- Overwriting pointer: ptr = new X; ptr = new Y; loses first\n\nFix: wrap in std::unique_ptr, std::shared_ptr, or RAII wrappers."}}