Anteru's blog
  • Consulting
  • Research
    • Assisted environment probe placement
    • Assisted texture assignment
    • Edge-Friend: Fast and Deterministic Catmull-Clark Subdivision Surfaces
    • Error Metrics for Smart Image Refinement
    • High-Quality Shadows for Streaming Terrain Rendering
    • Hybrid Sample-based Surface Rendering
    • Interactive rendering of Giga-Particle Fluid Simulations
    • Quantitative Analysis of Voxel Raytracing Acceleration Structures
    • Real-time Hybrid Hair Rendering
    • Real-Time Procedural Generation with GPU Work Graphs
    • Scalable rendering for very large meshes
    • Spatiotemporal Variance-Guided Filtering for Motion Blur
    • Subpixel Reconstruction Antialiasing
    • Tiled light trees
    • Towards Practical Meshlet Compression
  • About
  • Archive

C++ tricks, #5: Breaking on memory allocations with VC

July 19, 2007
  • Programming
approximately 1 minutes to read

A little known feature is breaking on a specific memory allocation without recompiling your app. Let’s assume you’ve run your code with _CrtDumpMemoryLeaks (); and you got something like

Detected memory leaks!
Dumping objects ->
{12213} normal block at 0x004DA780, 4 bytes long.
    Data: <4x  > 34 78 B5 00
Object dump complete.

Now, you want to track that down. Nothing simpler than that! Fire up your program in the debugger (I suggest running “Debug”, “Step into” to stop right at the first instruction), open your immediate window and enter:

{,,msvcr80d.dll}_crtBreakAlloc = 12213

This will work if you are linking against the multi-threaded DLLs (default with VC8), otherwise you can enter:

_crtBreakAlloc = 12213

Continue and you’ll get a “buggy_app.exe has triggered a breakpoint” as soon as you hit this allocation, and unless you’ve killed your stack you should see the location in the call stack.

Previous post
Next post

Recent posts

  • Data formats: Why CSV and JSON aren't the best
    Posted on 2024-12-29
  • Replacing cron with systemd-timers
    Posted on 2024-04-21
  • Open Source Maintenance
    Posted on 2024-04-02
  • Angular, Caddy, Gunicorn and Django
    Posted on 2023-10-21
  • Effective meetings
    Posted on 2022-09-12
  • Older posts

Find me on the web

  • GitHub
  • GPU database
  • Projects

Follow me

Anteru NIV_Anteru
Contents © 2005-2025
Anteru
Imprint/Impressum
Privacy policy/Datenschutz
Made with Liara
Last updated February 21, 2019