phantom <module>.net(uint) ?

Use this forum for questions on how to use .NET Memory Profiler and how to analyse memory usage.
Post Reply
kbirger
Posts: 1
Joined: Thu Mar 19, 2009 6:28 pm

phantom <module>.net(uint) ?

Post by kbirger » Thu Mar 19, 2009 6:34 pm

I'm new to using this program, but I seem to have tracked down a memory leak to the following stack:

Code: Select all

Kernel-HeapMemory

NtAllocateVirtualMemory(  )
HeapAlloc(  )
HeapAlloc(  )
[Managed to unmanaged transition]
<Module>.new(uint)
<Module>.someVclass.InTunnelPositionObject(CCoreTerrain*, CCoreTerrain*, CCoreTerrain*, double, double)
....snip...
now my C++ isn't great, but I'm looking at that method (InTunnelPositionObject) and I am not seeing anything that calls new unsigned int...

The method contains a for loop with an indexer of type unsigned int, and compares that to the result of another method at each iteration, but those are the only two uints I see in here, and they should not be being allocated to the heap.

I am wondering if I am either reading the output of .net memory profiler wrong, or if there might be a mistake in the profiler.

Andreas Suurkuusk
Posts: 1029
Joined: Wed Mar 02, 2005 7:53 pm

Post by Andreas Suurkuusk » Thu Mar 19, 2009 7:33 pm

The call stack for the allocation is normal when native memory is allocated using Managed C++. For instance, consider the program below:

Code: Select all

class SomeClass
{
  int a;
};

int main(array<System::String ^> ^args)
{
  new SomeClass();

  return 0;
}
The allocation call stack for the native class SomeClass (new SomeClass) looks like:

Code: Select all

HeapAlloc(  )
[Managed to unmanaged transition]
<Module>.new(uint)
<Module>.main(string[])
<Module>.mainCRTStartupStrArray(string[])
The uint parameter (it's actually a size_t parameter) in new(uint) specifies the size of the memory to allocate.

So, if the InTunnelPositionObject creates any native object using the new operator, you will see call stacks like the one you provided.
Best regards,

Andreas Suurkuusk
SciTech Software AB

Post Reply

Who is online

Users browsing this forum: No registered users and 16 guests