Skip to content

How-ToRAM

KERNEL_MODE_HEAP_CORRUPTION in Windows 11: What It Means and How to Fix It

KERNEL_MODE_HEAP_CORRUPTION (bug check 0x13A) means Windows' kernel heap manager has found damaged memory, sometimes well after the damage was done. Here's how to read parameter 1, catch the driver with Driver Verifier's Special Pool and rule out unstable RAM.

By , Systems & Technical Editor

6 min read

KERNEL_MODE_HEAP_CORRUPTION in Windows 11: What It Means and How to Fix It

KERNEL_MODE_HEAP_CORRUPTION is a blue screen that tells you something has damaged a block of memory the Windows kernel was managing, but not what did the damage. That makes it frustrating to fix, because the program that crashes is often the victim rather than the culprit. The good news is that the stop code carries a small clue that's worth reading, and the usual suspects are the same few things: a kernel driver, unstable memory settings or, less often, faulty RAM. The definitions and tools below come from Microsoft's documentation, and the order of the checks is our advice.

What the error actually means

Microsoft lists KERNEL_MODE_HEAP_CORRUPTION as bug check 0x13A (full value 0x0000013A) and says it "indicates that the kernel mode heap manager has detected corruption in a heap".

A heap is a pool of memory that code borrows blocks from and hands back when it's finished. Each block has a small header that the heap manager uses for bookkeeping. If code writes past the end of its block, writes before the start of it, or keeps using a block after handing it back, it tramples on those headers or on a neighbour's data. The next time the heap manager touches that area, it notices the damage and Windows stops the PC rather than carry on.

The key point is timing. The crash happens when the damage is detected, which can be some time after it was done. So the driver or process named on the blue screen isn't always the one responsible.

Step 1: Note parameter 1

Microsoft's reference page explains that the first of the four stop code parameters gives the "Type of corruption detected", the second is the address of the heap that reported the problem and the third is the address where the corruption was found. If the PC restarts before you can read the screen, look in Event Viewer's System log after Windows starts. Microsoft's guide to analysing bug check data says the bug check event records the stop code parameters.

Microsoft's list has more than 20 values. These are the ones most useful for working out what kind of mistake happened:

Parameter 1

What Microsoft says it means

0x3

A corrupt entry header was detected

0x4

Multiple corrupt entry headers were detected

0x6

A corruption was detected with features consistent with a buffer overrun

0x7

A corruption was detected with features consistent with a buffer underrun

0xB

An error whose features are consistent with using a block after freeing it

0xD

A corrupt free list, which can be the result of a use-after-free error or a buffer overflow of an adjacent block

0x11

Invalid internal state, which can be the result of a double-free or heap corruption

0x14

The requested heap allocation is larger than the current allocation limit

0x16

An internal heap error, which can be the result of a bad address or memory corruption

0x17

A block was corrupted in a delay free list, likely a use-after-free error or a buffer overflow of an adjacent block

How we'd read it:

  • Overrun, underrun, use-after-free and double-free values (0x6, 0x7, 0xB, 0xD, 0x11, 0x17) describe classic programming mistakes. That points first at a kernel driver, so start with Steps 2 and 3.

  • Header and internal-error values (0x3, 0x4, 0x16) describe damage without saying how it happened. Software is still the most likely cause, but if the value and the program named on the blue screen change from crash to crash, unstable memory becomes more of a suspect (Step 4).

Microsoft's page is written for developers and points them to the !analyze and !heap debugger extensions. If Windows saved a crash dump, our minidump analysis guide shows how to open it in WinDbg and run !analyze -v to see which module was involved.

Step 2: Undo recent changes and update

Microsoft's advanced troubleshooting guide estimates "that about 75 percent of all stop errors are caused by faulty drivers", so think about what changed just before the crashes began.

  • New hardware. Microsoft's support page suggests you "Remove any new hardware" added before the error, restart and see whether it stops.

  • New software with kernel drivers. As our advice, roll back or uninstall anything that installed a low-level driver around the time the crashes started. Typical examples are graphics driver updates, RGB and fan-control utilities, VPNs, virtual audio devices, anti-cheat systems and third-party antivirus.

  • Updates. Microsoft's general steps include installing current Windows updates and checking that "the BIOS and firmware are up-to-date". In Device Manager, look for devices marked with an exclamation point and select Update driver. For graphics, chipset and network drivers we'd go to the hardware maker's own download page.

If the PC crashes before you can do any of this, Microsoft suggests starting in safe mode and working through the remaining steps from there.

Step 3: Catch the driver in the act with Driver Verifier

Because heap corruption is often detected late, the most reliable way to find the culprit is to make Windows check driver memory use as it happens. That's what Driver Verifier is for. Microsoft says Driver Verifier "can allocate driver memory from a special pool and monitor that pool for incorrect access". Special Pool's default alignment favours catching overruns, which Microsoft says "are much more common in drivers than underrun errors". Microsoft says violations are typically reported as bug check 0xC4 (DRIVER_VERIFIER_DETECTED_VIOLATION), which gives you a much better lead on the driver responsible than a heap error detected some time later.

Read Microsoft's warnings first: Driver Verifier "consumes lots of CPU and can slow down the computer significantly", and you may get extra crashes while it's on. Create a restore point and back up before you start.

  1. Open Command Prompt with Run as administrator and type verifier.

  2. Choose Create custom settings if you want to pick options such as Special Pool and Pool Tracking yourself, or Create standard settings for Microsoft's default set.

  3. Choose Select driver names from a list. Microsoft suggests testing "suspicious" drivers first, such as ones that were recently updated, then moving on to third-party and unsigned drivers in groups of 10-20.

  4. Select Finish, restart and use the PC as normal, especially doing whatever usually triggered the crash.

When you're done, or if the PC becomes unusable, run verifier /reset from an administrator command prompt and restart. Our Driver Verifier guide covers reading the results in more detail.

Step 4: Rule out unstable memory

Heap corruption doesn't always come from bad code. If RAM returns the wrong data, the heap manager can see what looks like a damaged header even though no driver did anything wrong. Microsoft's last value in the table above, 0x16, explicitly includes "memory corruption" as a possible cause.

  • Go back to default memory settings. As our advice, if you use an XMP or EXPO profile or a manual memory or CPU overclock, turn it off in the BIOS for a few days. If the crashes stop, the parts may be fine but not fully stable at those settings. See our guide to crashes after enabling XMP or EXPO.

  • Test the RAM. Windows Memory Diagnostic is built in. Search for Memory in Control Panel, select Diagnose your computer's memory problems, then check the MemoryDiagnostics-Results entry in Event Viewer's System log afterwards. For a longer and more thorough test, use our MemTest86 guide, and test one stick at a time if errors appear.

Step 5: Repair Windows files, then restore

If the hardware checks out and Driver Verifier doesn't flag anything, repair Windows' own files. From an administrator command prompt, Microsoft says to run DISM.exe /Online /Cleanup-image /Restorehealth and then sfc /scannow. After that, Microsoft's next step is to go back to a restore point from before the problem started. If a clean Windows install still hits KERNEL_MODE_HEAP_CORRUPTION before you install any extra drivers, the problem is very likely hardware.

The bottom line

KERNEL_MODE_HEAP_CORRUPTION (bug check 0x13A) means Windows' kernel heap manager has found damaged memory bookkeeping, and the program named on the blue screen may only be the victim. Note parameter 1: overrun, underrun, use-after-free and double-free values point at a buggy kernel driver, so roll back recent driver changes, update Windows, drivers and the BIOS, and use Driver Verifier's Special Pool to catch the culprit. If the crashes are inconsistent, go back to default memory settings and test your RAM before repairing or restoring Windows.

Sources

  1. 01Bug check 0x13A: KERNEL_MODE_HEAP_CORRUPTION (Microsoft Learn)
  2. 02Advanced troubleshooting for stop or blue screen errors (Microsoft Learn)
  3. 03Analyze bug check (stop code error) data (Microsoft Learn)
  4. 04Driver Verifier (Microsoft Learn)
  5. 05Special Pool (Microsoft Learn)
  6. 06Bug Check 0x109: CRITICAL_STRUCTURE_CORRUPTION (Microsoft Learn)
  7. 07Troubleshooting Windows unexpected restarts and stop code errors (Microsoft Support)
  8. 08Use the System File Checker tool to repair missing or corrupted system files (Microsoft Support)

About the author

Marcus Thorne

Systems & Technical Editor

Marcus writes Forge PC's step-by-step build, troubleshooting and system optimisation guides. His background spans Windows kernel and power-state diagnostics, UEFI/BIOS configuration, NVMe storage arrays, ATX 3.1 power delivery and running local AI and LLM workloads on consumer graphics cards.

More from Marcus Thorne

Read next

BAD_POOL_CALLER in Windows 11: What Causes It and How to Fix It

How-To

BAD_POOL_CALLER in Windows 11: What Causes It and How to Fix It

BAD_POOL_CALLER (bug check 0xC2) means kernel code made an invalid memory pool request, such as freeing the same memory twice or using memory at the wrong IRQL, and it usually points to a faulty driver. Here's how to read parameter 1, use Driver Verifier's pool checks and rule out your RAM.

Marcus Thorne7 min