Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6745421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:12:09+00:00 2026-05-26T12:12:09+00:00

I have a .NET application that interops with native dll with following layers. a)

  • 0

I have a .NET application that interops with native dll with following layers.

a) C++ API GetNames() returns a list of wchar_t instances
b) C++/CLI API GetNames2() code calls into C++ API, marshall the list of wchar into .NET string, return this .NET string list
c) managed code C# calling interop layer GetNames2() API and display list of string

I am calling CoTaskMemFree API in interop layer to free natives wchar strings. However I am just wondering how to see memory leak caused by a missing CoTaskMemFree call. So I commented out call to CoTaskMemFree. In this case my understanding is that if I attach windbg and run !address -summary command, any allocations done on the native side (that haven’t been freed) should be shown under RegionUsageHeap but it does not seem to report it. Any ideas how can I see native memory usage (in context of managed code) within windbg?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T12:12:10+00:00Added an answer on May 26, 2026 at 12:12 pm

    The RegionUsageHeap is the total used for all native heaps, this value is incremented in quite large chunks, and there must be a quite huge memory leak to be observed in this variable.
    You can use the !heap command. The CoTaskMemAlloc uses default per-process heap, which usually is the first handle in the output from !heap –s , or look after “ProcessHeap” in the !peb output.
    When you have this handle use !heap –stat –h to see how many blocks there is allocated.
    You may also dump the entire heap, check the windbg help for the !heap command. Sample:

    0:011> !heap -stat -h 00150000   
    heap @ 00150000  
    group-by: TOTSIZE max-display: 20  
    size     #blocks     total     ( %) (percent of total busy bytes)  
    44      82f - 22c7c  (8.73)  
    20000     1 - 20000  (8.03) 
    <I have cut here>
    

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a .net managed application that interops with a native dll. Problem is
I have a .NET application that makes calls to a native Win32 DLL using
I have a .NET application that uses some API calls, for example GetPrivateProfileString .
I have a .NET WinForms application that I've converted into a COM dll using
I have a .net application that is doing COM interop and calling some native
Here's the core problem: I have a .NET application that is using COM interop
I have an application written in VB.NET that interacts with Excel via interop. I
I have a .NET application that is meant to be run on a local
I have a .NET application that processes around 300,000 records in a batch import,
I have a .NET application that I want to use as a client to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.