Sign in to follow this  

Memory Leaks

This topic is 4088 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi It seems my engine has a few memory leaks (15 to be precise) I have created an app with nothing going on other then creating a window and DirectX device then rendering nothing until the end. When I exit i get 15 DirectX warnings and a message box from ntdll.dll saying there has been some memory leaks. Okay so now ive installed purify and ive got the report back saying where the leaks are coming from. The problem is that i dont realy get which bit of my code evokes the problems if at all. Kernal32.dll and User32.dll are beyond my knowledge. Heres the report does anyone know how i can gleam some useful informiation from this?
[I] Summary of all memory leaks... {2768 bytes, 8 blocks}
    [I] MPK: Potential memory leak of 1964 bytes from 1 block allocated in GetMenuCheckMarkDimensions [USER32.dll]
            Offset 0x0000068c referenced by 0x00742743, a location in a section in the executable
            Distribution of potentially leaked blocks
                  1964 bytes from 1 block of 1964 bytes (0x0015b1e0)
            Allocation location
                LocalAlloc     [C:\WINDOWS\system32\KERNEL32.dll]
                GetMenuCheckMarkDimensions [C:\WINDOWS\system32\USER32.dll]
    [W] MLK: Memory leak of 488 bytes from 5 blocks allocated in GetMenuCheckMarkDimensions [USER32.dll]
            Distribution of leaked blocks
                   352 bytes from 1 block of 352 bytes (0x001531b0)
                   100 bytes from 1 block of 100 bytes (0x001576f8)
                    28 bytes from 1 block of 28 bytes (0x00157be0)
                     8 bytes from 2 blocks of 4 bytes (first block: 0x00153330)
            Allocation location
                LocalAlloc     [C:\WINDOWS\system32\KERNEL32.dll]
                GetMenuCheckMarkDimensions [C:\WINDOWS\system32\USER32.dll]
    [I] MPK: Potential memory leak of 264 bytes from 1 block allocated in RegEnumKeyA [ADVAPI32.dll]
            Offset 0x00000008 referenced by 0x0019dc00, a location in a HeapAlloc'd block
            Distribution of potentially leaked blocks
                   264 bytes from 1 block of 264 bytes (0x0019c4c8)
            Allocation location
                HeapAlloc      [C:\WINDOWS\system32\KERNEL32.dll]
                RegEnumKeyA    [C:\WINDOWS\system32\ADVAPI32.dll]
    [W] MLK: Memory leak of 52 bytes from 1 block allocated in GetMenuCheckMarkDimensions [USER32.dll]
            Distribution of leaked blocks
                    52 bytes from 1 block of 52 bytes (0x001588f0)
            Allocation location
                HeapAlloc      [C:\WINDOWS\system32\KERNEL32.dll]
                GetMenuCheckMarkDimensions [C:\WINDOWS\system32\USER32.dll]
[I] Exiting with code 0 (0x00000000)
        Process time: 10906 milliseconds
[I] Program terminated at 10/02/2006 15:57:10

Share this post


Link to post
Share on other sites
This really depends on how you've written the code. If you've used global objects, then there's a good chance the memory leak detection has kicked in before global destructors have been called, thus reporting spurious leaks. Without any code to go with the output you've provided, there's not much else to say.

Skizz

Share this post


Link to post
Share on other sites
Use the CRT debugging functions to track them down. _CrtDumpMemoryLeaks will dump the leaks at the end with allocation numbers and then there's a function like _CrtBreakOnAlloc(num) (may be slightly different name) where you can programmatically set a breakpoint when that leak is allocated.

Edit: Actually that doesn't sound like C++ you are using. What language/compiler are you using?

Share this post


Link to post
Share on other sites
Okay heres the debug output:

'VisualVector_PC.exe': Loaded 'C:\WINDOWS\system32\mslbui.dll', Symbols loaded.
Detected memory leaks!
Dumping objects ->
{128} normal block at 0x00C27730, 312 bytes long.
Data: <$ o D; ; > 24 9E 6F 00 00 00 FA 44 3B CD 13 BF 3B CD 13 BF
{127} normal block at 0x00C27470, 644 bytes long.
Data: < o > E0 9C 6F 00 CD CD CD CD CD CD CD CD CD CD CD CD
{87} normal block at 0x00C22F38, 260 bytes long.
Data: <c:\Documents and> 63 3A 5C 44 6F 63 75 6D 65 6E 74 73 20 61 6E 64
Object dump complete.
Unhandled exception at 0x7c901230 (ntdll.dll) in VisualVector_PC.exe: User breakpoint.

the data in the last one looks like a string containing a file name maybe?

Share this post


Link to post
Share on other sites
alright

theres just one left and its that last one

"Data: <c:\Documents and> 63 3A 5C 44 6F 63 75 6D 65 6E 74 73 20 61 6E 64 "

I know this is a std::string i use called mediaPath. Just to make sure, ive got the string as an actual instance (not a pointer) and im deleting it using string.erase(); is that right? or do i have to use delete? Also a more DirectX specific question - When i use D3DXMATRIX and D3DXVECTOR3 instances (rather then pointers) how do I delete them?

Share this post


Link to post
Share on other sites
You don't need to delete the string at all, if it's an object member or a local (stack) variable. Same thing for vectors and matrices -- if they are locals, or object members, they will be deleted when they go out of scope or their owning object is deleted.

Share this post


Link to post
Share on other sites

This topic is 4088 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this