HUGE fps jump

This is a discussion on HUGE fps jump within the Game Programming forums, part of the General Programming Boards category; if you're using MSVC, you can use the crtdbg library, which has one of my favorite functions, _CrtDumpMemoryLeaks(); That will ...

  1. #16
    vae victus! skorman00's Avatar
    Join Date
    Nov 2003
    Posts
    594
    if you're using MSVC, you can use the crtdbg library, which has one of my favorite functions, _CrtDumpMemoryLeaks(); That will display all the dynamic memory that is still allocated to the output window whenever you call it. I put it right before main or winmain returns, but you also have to take into account static/global pointers/objects, and local objects in main that have dynamic memory.

    However, as the '_' at the front of the function implies, it is an extension. I'm pretty sure it's only for MSVC. To use it, you need to include <stdlib.h> and <crtdbg.h> in that order. It will only work in debug, and doesn't do anything in a release mode, so you won't have to worry about performance hits. The crtdbg library can do lots of other stuff to, but I'll let you fiddle with that on your own.
    Last edited by skorman00; 06-29-2004 at 06:44 PM.

  2. #17
    Registered User
    Join Date
    Aug 2001
    Posts
    411
    hate to hijack this thread so much, but heres what that function gave me. It dosent mean a whole lot to me. I gather that its memory addresses and a sample of whats stored there, but how dose that help me to fix the leak?

    Code:
    Detected memory leaks!
    Dumping objects ->
    {149364} normal block at 0x0288E3B0, 33 bytes long.
     Data: < Terrain Polys => 00 54 65 72 72 61 69 6E 20 50 6F 6C 79 73 20 3D 
    {147961} normal block at 0x0288B3C0, 16 bytes long.
     Data: <                > CC CD CD CD B1 E3 88 02 13 00 00 00 1F 00 00 00 
    {147954} normal block at 0x0747C0B0, 160000 bytes long.
     Data: <                > CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD 
    {147953} normal block at 0x0288C030, 8 bytes long.
     Data: <  G     > B0 C0 47 07 C8 00 CD CD 
    {137900} normal block at 0x07470068, 49152 bytes long.
     Data: <   ?   >   >   ?> 97 B6 16 3F F2 10 F2 3E AD 92 AC 3E 9C 8C 0B 3F 
    {133713} normal block at 0x05852310, 49152 bytes long.
     Data: < N/? @!? 3 ? ! ?> AF 4E 2F 3F A1 40 21 3F 94 33 14 3F 11 21 20 3F 
    {133704} normal block at 0x058462C8, 49152 bytes long.
     Data: <   ?   >   >   ?> 97 B6 16 3F F2 10 F2 3E AD 92 AC 3E 9C 8C 0B 3F 
    {133495} normal block at 0x0583A280, 49152 bytes long.
     Data: <   ?   >   >   ?> 97 B6 16 3F F2 10 F2 3E AD 92 AC 3E 9C 8C 0B 3F 
    {132510} normal block at 0x0582E238, 49152 bytes long.
     Data: < N/? @!? 3 ? / ?> AF 4E 2F 3F A1 40 21 3F 94 33 14 3F 00 2F 1F 3F 
    {132302} normal block at 0x058221F0, 49152 bytes long.
     Data: < N/? @!? 3 ?   ?> AF 4E 2F 3F A1 40 21 3F 94 33 14 3F A0 82 1F 3F 
    {132262} normal block at 0x058161A8, 49152 bytes long.
     Data: < N/? @!? 3 ? / ?> AF 4E 2F 3F A1 40 21 3F 94 33 14 3F 00 2F 1F 3F 
    {132253} normal block at 0x0580A160, 49152 bytes long.
     Data: <  I?  $?   >  G?> C9 14 49 3F A5 B0 24 3F EA 80 E9 3E C7 1E 47 3F 
    {127272} normal block at 0x057FE118, 49152 bytes long.
     Data: <  I?  $?   >V F?> C9 14 49 3F A5 B0 24 3F EA 80 E9 3E 56 80 46 3F 
    {127064} normal block at 0x057F20D0, 49152 bytes long.
     Data: <  I?  $?   >  G?> C9 14 49 3F A5 B0 24 3F EA 80 E9 3E C7 1E 47 3F 
    {125597} normal block at 0x057E6088, 49152 bytes long.
     Data: <   ?   >   >   ?> 97 B6 16 3F F2 10 F2 3E AD 92 AC 3E 9C 8C 0B 3F 
    {125389} normal block at 0x057C9FF8, 49152 bytes long.
     Data: <   ?   >   >   ?> 97 B6 16 3F F2 10 F2 3E AD 92 AC 3E 8B 9A 0A 3F 
    {124984} normal block at 0x057BDFB0, 49152 bytes long.
     Data: < N/? @!? 3 ? ! ?> AF 4E 2F 3F A1 40 21 3F 94 33 14 3F 11 21 20 3F 
    {124975} normal block at 0x057B1F68, 49152 bytes long.
     Data: < N/? @!? 3 ?   ?> AF 4E 2F 3F A1 40 21 3F 94 33 14 3F A0 82 1F 3F 
    {124353} normal block at 0x057A5F20, 49152 bytes long.
     Data: <   ?   >   >   ?> 97 B6 16 3F F2 10 F2 3E AD 92 AC 3E 8B 9A 0A 3F 
    {124145} normal block at 0x05799ED8, 49152 bytes long.
     Data: <   ?   >   >   ?> 97 B6 16 3F F2 10 F2 3E AD 92 AC 3E 8B 9A 0A 3F 
    {123947} normal block at 0x0578DE90, 49152 bytes long.
     Data: < N/? @!? 3 ? / ?> AF 4E 2F 3F A1 40 21 3F 94 33 14 3F 00 2F 1F 3F 
    {123740} normal block at 0x05781E48, 49152 bytes long.
     Data: < N/? @!? 3 ?   ?> AF 4E 2F 3F A1 40 21 3F 94 33 14 3F A0 82 1F 3F 
    {123712} normal block at 0x05775E00, 49152 bytes long.
     Data: <   ?   >   >   ?> 97 B6 16 3F F2 10 F2 3E AD 92 AC 3E 9C 8C 0B 3F 
    {123523} normal block at 0x05769DB8, 49152 bytes long.
     Data: <  I?  $?   >V F?> C9 14 49 3F A5 B0 24 3F EA 80 E9 3E 56 80 46 3F 
    {123514} normal block at 0x0575DD70, 49152 bytes long.
     Data: < N/? @!? 3 ? / ?> AF 4E 2F 3F A1 40 21 3F 94 33 14 3F 00 2F 1F 3F 
    {123501} normal block at 0x05751D28, 49152 bytes long.
     Data: <   ?   >   >   ?> 97 B6 16 3F F2 10 F2 3E AD 92 AC 3E 8B 9A 0A 3F 
    {123274} normal block at 0x05745CE0, 49152 bytes long.
     Data: <   ?   >   >   ?> 97 B6 16 3F F2 10 F2 3E AD 92 AC 3E 9C 8C 0B 3F 
    {123265} normal block at 0x05739C98, 49152 bytes long.
     Data: <  I?  $?   >  G?> C9 14 49 3F A5 B0 24 3F EA 80 E9 3E C7 1E 47 3F 
    {122478} normal block at 0x0572DC50, 49152 bytes long.
     Data: < N/? @!? 3 ?   ?> AF 4E 2F 3F A1 40 21 3F 94 33 14 3F A0 82 1F 3F 
    {122469} normal block at 0x05721C08, 49152 bytes long.
     Data: <   ?   >   >   ?> 97 B6 16 3F F2 10 F2 3E AD 92 AC 3E 8B 9A 0A 3F 
    {122262} normal block at 0x05715BC0, 49152 bytes long.
     Data: <  I?  $?   >V F?> C9 14 49 3F A5 B0 24 3F EA 80 E9 3E 56 80 46 3F 
    {122253} normal block at 0x05709B78, 49152 bytes long.
     Data: <  I?  $?   > ,F?> C9 14 49 3F A5 B0 24 3F EA 80 E9 3E B6 2C 46 3F 
    {121835} normal block at 0x056FDB30, 49152 bytes long.
     Data: <  I?  $?   >  G?> C9 14 49 3F A5 B0 24 3F EA 80 E9 3E C7 1E 47 3F 
    {121632} normal block at 0x056F1AE8, 49152 bytes long.
     Data: <   ?   >   >   ?> 97 B6 16 3F F2 10 F2 3E AD 92 AC 3E 8B 9A 0A 3F 
    {121620} normal block at 0x056E5AA0, 49152 bytes long.
     Data: <  I?  $?   > ,F?> C9 14 49 3F A5 B0 24 3F EA 80 E9 3E B6 2C 46 3F 
    {121416} normal block at 0x056D9A58, 49152 bytes long.
     Data: <  I?  $?   > ,F?> C9 14 49 3F A5 B0 24 3F EA 80 E9 3E B6 2C 46 3F 
    {121405} normal block at 0x056CDA10, 49152 bytes long.
     Data: <  I?  $?   > ,F?> C9 14 49 3F A5 B0 24 3F EA 80 E9 3E B6 2C 46 3F 
    {121396} normal block at 0x056C19C8, 49152 bytes long.
     Data: <  I?  $?   >  G?> C9 14 49 3F A5 B0 24 3F EA 80 E9 3E C7 1E 47 3F 
    {120250} normal block at 0x056B5980, 49152 bytes long.
     Data: < N/? @!? 3 ? ! ?> AF 4E 2F 3F A1 40 21 3F 94 33 14 3F 11 21 20 3F 
    {119639} normal block at 0x056A9938, 49152 bytes long.
     Data: < N/? @!? 3 ? ! ?> AF 4E 2F 3F A1 40 21 3F 94 33 14 3F 11 21 20 3F 
    {119630} normal block at 0x0569D8F0, 49152 bytes long.
     Data: <  I?  $?   >  G?> C9 14 49 3F A5 B0 24 3F EA 80 E9 3E C7 1E 47 3F 
    {119428} normal block at 0x056918A8, 49152 bytes long.
     Data: < N/? @!? 3 ?   ?> AF 4E 2F 3F A1 40 21 3F 94 33 14 3F A0 82 1F 3F 
    {119414} normal block at 0x05685860, 49152 bytes long.
     Data: <  I?  $?   >  G?> C9 14 49 3F A5 B0 24 3F EA 80 E9 3E C7 1E 47 3F 
    {119206} normal block at 0x05679818, 49152 bytes long.
     Data: < G ? G ? G ? ^ ?> 98 47 18 3F 98 47 18 3F 98 47 18 3F BE 5E 15 3F 
    {119001} normal block at 0x0566D7D0, 49152 bytes long.
     Data: < N/? @!? 3 ?   ?> AF 4E 2F 3F A1 40 21 3F 94 33 14 3F A0 82 1F 3F 
    {118991} normal block at 0x05661788, 49152 bytes long.
     Data: < G ? G ? G ?N  ?> 98 47 18 3F 98 47 18 3F 98 47 18 3F 4E C0 14 3F 
    {118785} normal block at 0x05655740, 49152 bytes long.
     Data: < G ? G ? G ?N  ?> 98 47 18 3F 98 47 18 3F 98 47 18 3F 4E C0 14 3F 
    {118776} normal block at 0x056496F8, 49152 bytes long.
     Data: < G ? G ? G ?N  ?> 98 47 18 3F 98 47 18 3F 98 47 18 3F 4E C0 14 3F 
    {118767} normal block at 0x0563D6B0, 49152 bytes long.
     Data: < G ? G ? G ?   ?> 98 47 18 3F 98 47 18 3F 98 47 18 3F 95 94 14 3F 
    {116944} normal block at 0x05631668, 49152 bytes long.
     Data: <  I?  $?   >  G?> C9 14 49 3F A5 B0 24 3F EA 80 E9 3E C7 1E 47 3F 
    {116932} normal block at 0x05625620, 49152 bytes long.
     Data: < G ? G ? G ? ^ ?> 98 47 18 3F 98 47 18 3F 98 47 18 3F BE 5E 15 3F 
    {116728} normal block at 0x056195D8, 49152 bytes long.
     Data: < G ? G ? G ? ^ ?> 98 47 18 3F 98 47 18 3F 98 47 18 3F BE 5E 15 3F 
    {116717} normal block at 0x0560D590, 49152 bytes long.
     Data: < G ? G ? G ? ^ ?> 98 47 18 3F 98 47 18 3F 98 47 18 3F BE 5E 15 3F 
    {116708} normal block at 0x05601548, 49152 bytes long.
     Data: < G ? G ? G ?   ?> 98 47 18 3F 98 47 18 3F 98 47 18 3F 95 94 14 3F 
    {115490} normal block at 0x055F5500, 49152 bytes long.
     Data: <  I?  $?   >  G?> C9 14 49 3F A5 B0 24 3F EA 80 E9 3E C7 1E 47 3F 
    {115088} normal block at 0x055E94B8, 49152 bytes long.
     Data: < G ? G ? G ?   ?> 98 47 18 3F 98 47 18 3F 98 47 18 3F 95 94 14 3F 
    {115077} normal block at 0x055DD470, 49152 bytes long.
     Data: <  I?  $?   > TF?> C9 14 49 3F A5 B0 24 3F EA 80 E9 3E 9E 54 46 3F 
    {114872} normal block at 0x055D1428, 49152 bytes long.
     Data: <  I?  $?   > TF?> C9 14 49 3F A5 B0 24 3F EA 80 E9 3E 9E 54 46 3F 
    {114862} normal block at 0x055C53E0, 49152 bytes long.
     Data: <  I?  $?   > TF?> C9 14 49 3F A5 B0 24 3F EA 80 E9 3E 9E 54 46 3F 
    {114853} normal block at 0x055B9398, 49152 bytes long.
     Data: <  I?  $?   >  G?> C9 14 49 3F A5 B0 24 3F EA 80 E9 3E C7 1E 47 3F 
    {107482} normal block at 0x05582208, 160000 bytes long.
     Data: <                > 0F 03 00 00 10 03 00 00 11 03 00 00 12 03 00 00 
    {107481} normal block at 0x0288EF60, 8 bytes long.
     Data: < "X     > 08 22 58 05 C8 00 CD CD 
    {107480} normal block at 0x0288EFA0, 16 bytes long.
     Data: < Y      <   A7  > 17 59 89 C1 F4 98 88 C1 3C 87 8F C1 41 37 90 C1 
    {107469} normal block at 0x0555AA80, 161604 bytes long.
     Data: <1  BV  B   B   B> 31 FD 12 42 56 9A 13 42 F7 FA 13 42 BE 9F 14 42 
    {107468} normal block at 0x0288EFE0, 8 bytes long.
     Data: <  U     > 80 AA 55 05 C9 00 CD CD 
    {107455} normal block at 0x055332F8, 161604 bytes long.
     Data: <DI3A  2A  /Am 'A> 44 49 33 41 9F F6 32 41 E0 20 2F 41 6D D4 27 41 
    {107454} normal block at 0x028888A0, 8 bytes long.
     Data: < 2S     > F8 32 53 05 C9 00 CD CD 
    {106986} normal block at 0x02888DE0, 10 bytes long.
     Data: <56 000    > 35 36 00 30 30 30 00 CD CD CD 
    {82324} normal block at 0x0288ECC0, 33 bytes long.
     Data: < Terrain Polys => 00 54 65 72 72 61 69 6E 20 50 6F 6C 79 73 20 3D 
    {81355} normal block at 0x028881D0, 16 bytes long.
     Data: <                > CC CD CD CD C1 EC 88 02 13 00 00 00 1F 00 00 00 
    {81348} normal block at 0x054D1A90, 202500 bytes long.
     Data: <                > CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD 
    {81347} normal block at 0x028886D0, 8 bytes long.
     Data: <  M     > 90 1A 4D 05 E1 00 CD CD 
    {75714} normal block at 0x054C5A48, 49152 bytes long.
     Data: < x > | >  D> z >> B9 78 B9 3E BD 7C BD 3E C5 90 44 3E B4 7A B4 3E 
    {74546} normal block at 0x054B9A00, 49152 bytes long.
     Data: < x > | >  D>   >> B9 78 B9 3E BD 7C BD 3E C5 90 44 3E FD BF B5 3E 
    {73898} normal block at 0x054AD9B8, 49152 bytes long.
     Data: <   ?   >   >   >> 84 8B 03 3F BB 88 BA 3E 9C F2 9B 3E D9 BF B0 3E 
    {73888} normal block at 0x054A1970, 49152 bytes long.
     Data: <   ?   >   >   >> 84 8B 03 3F BB 88 BA 3E 9C F2 9B 3E D9 BF B0 3E 
    {71099} normal block at 0x05495928, 49152 bytes long.
     Data: < x > | >  D>   >> B9 78 B9 3E BD 7C BD 3E C5 90 44 3E FD BF B5 3E 
    {71089} normal block at 0x054898E0, 49152 bytes long.
     Data: < c ?   ?   >   ?> 8C 63 0C 3F 90 A3 0F 3F F8 F6 F7 3E 83 E6 02 3F 
    {68609} normal block at 0x0547D898, 49152 bytes long.
     Data: < c ?   ?   >   ?> 8C 63 0C 3F 90 A3 0F 3F F8 F6 F7 3E 83 E6 02 3F 
    {68148} normal block at 0x05471850, 49152 bytes long.
     Data: < c ?   ?   >   ?> 8C 63 0C 3F 90 A3 0F 3F F8 F6 F7 3E 83 E6 02 3F 
    {67934} normal block at 0x05465808, 49152 bytes long.
     Data: <   ? 6 >   >v, ?> 85 A8 04 3F EF 36 EF 3E CC 92 CB 3E 76 2C 02 3F 
    {67921} normal block at 0x054597C0, 49152 bytes long.
     Data: <   ? 6 >   >   ?> 85 A8 04 3F EF 36 EF 3E CC 92 CB 3E D1 89 01 3F 
    {67887} normal block at 0x0544D778, 49152 bytes long.
     Data: <   ? 6 >   > ) ?> 85 A8 04 3F EF 36 EF 3E CC 92 CB 3E 82 29 02 3F 
    {67877} normal block at 0x05441730, 49152 bytes long.
     Data: < c ?   ?   >   ?> 8C 63 0C 3F 90 A3 0F 3F F8 F6 F7 3E 8F E3 02 3F 
    {67795} normal block at 0x054356E8, 49152 bytes long.
     Data: < c ?   ?   >J< ?> 8C 63 0C 3F 90 A3 0F 3F F8 F6 F7 3E 4A 3C 02 3F 
    {67638} normal block at 0x054296A0, 49152 bytes long.
     Data: < c ?   ?   >   ?> 8C 63 0C 3F 90 A3 0F 3F F8 F6 F7 3E 8F E3 02 3F 
    {67629} normal block at 0x0541D658, 49152 bytes long.
     Data: < c ?   ?   >   ?> 8C 63 0C 3F 90 A3 0F 3F F8 F6 F7 3E 8F E3 02 3F 
    {67620} normal block at 0x05411610, 49152 bytes long.
     Data: < c ?   ?   >   ?> 8C 63 0C 3F 90 A3 0F 3F F8 F6 F7 3E 83 E6 02 3F 
    {67594} normal block at 0x054055C8, 49152 bytes long.
     Data: <   ? 6 >   >=  ?> 85 A8 04 3F EF 36 EF 3E CC 92 CB 3E 3D 82 01 3F 
    {67585} normal block at 0x053F9580, 49152 bytes long.
     Data: <   ?   >   >"  >> 84 8B 03 3F BB 88 BA 3E 9C F2 9B 3E 22 05 B2 3E 
    {67521} normal block at 0x053ED538, 49152 bytes long.
     Data: < c ?   ?   >J< ?> 8C 63 0C 3F 90 A3 0F 3F F8 F6 F7 3E 4A 3C 02 3F 
    {67512} normal block at 0x053E14F0, 49152 bytes long.
     Data: <   ?   >   >   >> 84 8B 03 3F BB 88 BA 3E 9C F2 9B 3E B1 B0 B0 3E 
    {67133} normal block at 0x053D54A8, 49152 bytes long.
     Data: < c ?   ?   >   ?> 8C 63 0C 3F 90 A3 0F 3F F8 F6 F7 3E 83 E6 02 3F 
    {66821} normal block at 0x053C9460, 49152 bytes long.
     Data: <   ?   >   >   >> 84 8B 03 3F BB 88 BA 3E 9C F2 9B 3E B1 B0 B0 3E 
    {66665} normal block at 0x053BD418, 49152 bytes long.
     Data: < c ?   ?   >   ?> 8C 63 0C 3F 90 A3 0F 3F F8 F6 F7 3E 83 E6 02 3F 
    {66651} normal block at 0x053B13D0, 49152 bytes long.
     Data: <   ? 6 >   >v, ?> 85 A8 04 3F EF 36 EF 3E CC 92 CB 3E 76 2C 02 3F 
    {66424} normal block at 0x053A5388, 49152 bytes long.
     Data: <   ? 6 >   >v, ?> 85 A8 04 3F EF 36 EF 3E CC 92 CB 3E 76 2C 02 3F 
    {66411} normal block at 0x05399340, 49152 bytes long.
     Data: <   ? 6 >   >v, ?> 85 A8 04 3F EF 36 EF 3E CC 92 CB 3E 76 2C 02 3F 
    {66402} normal block at 0x0538D2F8, 49152 bytes long.
     Data: <   ? 6 >   > ) ?> 85 A8 04 3F EF 36 EF 3E CC 92 CB 3E 82 29 02 3F 
    {65890} normal block at 0x053812B0, 49152 bytes long.
     Data: < c ?   ?   >   ?> 8C 63 0C 3F 90 A3 0F 3F F8 F6 F7 3E 83 E6 02 3F 
    {65873} normal block at 0x05375268, 49152 bytes long.
     Data: <   ?   >   >"  >> 84 8B 03 3F BB 88 BA 3E 9C F2 9B 3E 22 05 B2 3E 
    {65649} normal block at 0x05369220, 49152 bytes long.
     Data: <   ?   >   >"  >> 84 8B 03 3F BB 88 BA 3E 9C F2 9B 3E 22 05 B2 3E 
    {65633} normal block at 0x0535D1D8, 49152 bytes long.
     Data: <   ?   >   >"  >> 84 8B 03 3F BB 88 BA 3E 9C F2 9B 3E 22 05 B2 3E 
    {65624} normal block at 0x05351190, 49152 bytes long.
     Data: <   ?   >   >   >> 84 8B 03 3F BB 88 BA 3E 9C F2 9B 3E B1 B0 B0 3E 
    {62675} normal block at 0x05345148, 49152 bytes long.
     Data: <   ?   >   >   >> 84 8B 03 3F BB 88 BA 3E 9C F2 9B 3E B1 B0 B0 3E 
    {62442} normal block at 0x05339100, 49152 bytes long.
     Data: < x > | >  D> k >> B9 78 B9 3E BD 7C BD 3E C5 90 44 3E 8C 6B B4 3E 
    {62215} normal block at 0x0532D0B8, 49152 bytes long.
     Data: < x > | >  D> z >> B9 78 B9 3E BD 7C BD 3E C5 90 44 3E B4 7A B4 3E 
    {61571} normal block at 0x05321070, 49152 bytes long.
     Data: <   ? 6 >   >=  ?> 85 A8 04 3F EF 36 EF 3E CC 92 CB 3E 3D 82 01 3F 
    {60660} normal block at 0x05315028, 49152 bytes long.
     Data: <   ?   >   >   >> 84 8B 03 3F BB 88 BA 3E 9C F2 9B 3E B1 B0 B0 3E 
    {60427} normal block at 0x05308FE0, 49152 bytes long.
     Data: <   ? 6 >   >=  ?> 85 A8 04 3F EF 36 EF 3E CC 92 CB 3E 3D 82 01 3F 
    {60418} normal block at 0x052FCF98, 49152 bytes long.
     Data: <   ?   >   >   >> 84 8B 03 3F BB 88 BA 3E 9C F2 9B 3E B1 B0 B0 3E 
    {60185} normal block at 0x052F0F50, 49152 bytes long.
     Data: <   ?   >   >   >> 84 8B 03 3F BB 88 BA 3E 9C F2 9B 3E B1 B0 B0 3E 
    {60174} normal block at 0x052E4F08, 49152 bytes long.
     Data: < x > | >  D> k >> B9 78 B9 3E BD 7C BD 3E C5 90 44 3E 8C 6B B4 3E 
    {59944} normal block at 0x052D8EC0, 49152 bytes long.
     Data: <   >   >  9> O(?> B6 B4 B5 3E 90 C6 8F 3E B9 18 39 3E B8 4F 28 3F 
    {59935} normal block at 0x052CCE78, 49152 bytes long.
     Data: < x > | >  D> k >> B9 78 B9 3E BD 7C BD 3E C5 90 44 3E 8C 6B B4 3E 
    {59926} normal block at 0x052C0E30, 49152 bytes long.
     Data: < x > | >  D> k >> B9 78 B9 3E BD 7C BD 3E C5 90 44 3E 8C 6B B4 3E 
    {59917} normal block at 0x052B4DE8, 49152 bytes long.
     Data: < x > | >  D> z >> B9 78 B9 3E BD 7C BD 3E C5 90 44 3E B4 7A B4 3E 
    {56977} normal block at 0x052A8DA0, 49152 bytes long.
     Data: < x > | >  D> z >> B9 78 B9 3E BD 7C BD 3E C5 90 44 3E B4 7A B4 3E 
    {55522} normal block at 0x0529CD58, 49152 bytes long.
     Data: < 2 >   >   >   >> DB 32 DB 3E F0 0E F0 3E 93 FA 92 3E A5 DE E5 3E 
    {55188} normal block at 0x05290D10, 49152 bytes long.
     Data: < c ?   ?   ><  ?> 8C 63 0C 3F 90 A3 0F 3F F8 F6 F7 3E 3C 81 03 3F 
    {54636} normal block at 0x05284CC8, 49152 bytes long.
     Data: < G ?   >   >   ?> 88 47 08 3F DA B0 D9 3E C7 AC C6 3E EE 03 12 3F 
    {54627} normal block at 0x05278C80, 49152 bytes long.
     Data: < x > | >  D> z >> B9 78 B9 3E BD 7C BD 3E C5 90 44 3E B4 7A B4 3E 
    {54395} normal block at 0x0526CC38, 49152 bytes long.
     Data: < x > | >  D> ? >> B9 78 B9 3E BD 7C BD 3E C5 90 44 3E FE 3F B6 3E 
    {54386} normal block at 0x05260BF0, 49152 bytes long.
     Data: < x > | >  D> z >> B9 78 B9 3E BD 7C BD 3E C5 90 44 3E B4 7A B4 3E 
    {50348} normal block at 0x05254BA8, 49152 bytes long.
     Data: < x > | >  D>   >> B9 78 B9 3E BD 7C BD 3E C5 90 44 3E FD BF B5 3E 
    {50128} normal block at 0x05248B60, 49152 bytes long.
     Data: < c ?   ?   > C ?> 8C 63 0C 3F 90 A3 0F 3F F8 F6 F7 3E DE 43 02 3F 
    {49816} normal block at 0x0523CB18, 49152 bytes long.
     Data: < x > | >  D>   >> B9 78 B9 3E BD 7C BD 3E C5 90 44 3E FD BF B5 3E 
    {49807} normal block at 0x05230AD0, 49152 bytes long.
     Data: <   >   >  9>  (?> B6 B4 B5 3E 90 C6 8F 3E B9 18 39 3E F1 F9 28 3F 
    {49747} normal block at 0x05224A88, 49152 bytes long.
     Data: < 2 >   >   >   >> DB 32 DB 3E F0 0E F0 3E 93 FA 92 3E A5 DE E5 3E 
    {49738} normal block at 0x05218A40, 49152 bytes long.
     Data: < c ?   ?   >   ?> 8C 63 0C 3F 90 A3 0F 3F F8 F6 F7 3E 83 E6 02 3F 
    {49157} normal block at 0x0520C9F8, 49152 bytes long.
     Data: < x > | >  D>   >> B9 78 B9 3E BD 7C BD 3E C5 90 44 3E FD BF B5 3E

  3. #18
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    Quote Originally Posted by Eber Kain
    hate to hijack this thread so much, but heres what that function gave me. It dosent mean a whole lot to me. I gather that its memory addresses and a sample of whats stored there, but how dose that help me to fix the leak?

    Code:
     Detected memory leaks!
     Dumping objects ->
    
     ..snip millions of leaks
    You got a lot of leaks buddy. Anyways, if you have a central header file like StdAfx or something you add the following lines:

    Code:
     #ifdef _MSC_VER
     #include <crtdbg.h>
     #endif
     
     #ifdef _DEBUG
     #define new new(_NORMAL_BLOCK, __FILE__, __LINE__)
     #endif
    Then in the beginning of your app entry point you put:

    Code:
     #ifdef _MSC_VER 
       // Enable memory leak detection.
     	// Get the old value of the CRT debug flags.
     	int OldValue = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
     
     	_CrtSetDbgFlag(OldValue | _CRTDBG_LEAK_CHECK_DF);
     #endif
    Then whenever you run your app with F5 "debug run" with VC++ , it will automatically dump your memory leaks and you can click on them to go to the exact line of the allocation. Enjoy.
    "...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

  4. #19
    vae victus! skorman00's Avatar
    Join Date
    Nov 2003
    Posts
    594
    If you #define _CRTDBG_MAP_ALLOC_ before those two #includes, it should also output the line where the memory was allocated for that block....maybe. I've had it act funny sometimes, and tell me the leak is in crtdbg.h. You might also want to check out some of the other functions the crtdbg library has. They all begin with _Crt.

    If it won't find the correct line's the memory was allocated for you, the only thing you can really do is determine what object is 33 bytes long and has "Terrain Polys=" in it's first data member, what object you have that takes up 49152 bytes, etc. This one looks particularly suspcious:
    Code:
    {147954} normal block at 0x0747C0B0, 160000 bytes long.
     Data: <                > CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD
    Big memory block that seems to not have been intialized (tsk tsk =) ).

    I've found that the best way to use _CrtDumpMemoryLeaks() is to use it from the start of developement, and that way it will pick up the leaks as you go along. Unfortunately, you can't do that right now, but by looking at the size of the leak, you should be able to track it down pretty easily.

  5. #20
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    What has worked for me Eber is to create empty destructors. Specifically create a shutdown method for all your objects. This way you know exactly when the object is destroyed because you called shutdown() for it. In shutdown() you would return any memory allocated back to the system, and release all COM interfaces that were used by the object preferably in the reverse order that you created or retrieved pointers to them. Sort of like unwinding a stack, first on last off.

    I used to put all this in the destructor code itself but it was hard to track when and if an object went out of scope and should clean up. Do what works for you but this has helped me a lot. I don't like to rely on an implicit destructor call to clean up my objects. I'd rather use my own call and function to do it. Then when the object goes out of scope or is deleted...all the compiler has to do is de-allocate the memory that the object took. All other pointers have already been taken care of by you.

    Also I know Direct3D has retail and debug dlls. The debug DLLs can dump quite a bit of debug info right into the MSVC IDE and are very useful. Perhaps OpenGL has something similar to this.

  6. #21
    Registered User
    Join Date
    Aug 2001
    Posts
    411
    Thanks for pointing me to this guys. I found this page which helped me to set up the leak detection. http://www.flipcode.com/cgi-bin/msg....rum=totd&id=-1


    After hacking away at it for about an hour I fixed them all excep these.
    Code:
    Detected memory leaks!
    Dumping objects ->
    C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\crtdbg.h(552) : {1420} normal block at 0x0287B4A0, 5 bytes long.
     Data: <true > 74 72 75 65 00 
    C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\crtdbg.h(552) : {1419} normal block at 0x0287B4E0, 6 bytes long.
     Data: <false > 66 61 6C 73 65 00 
    C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\crtdbg.h(552) : {1418} normal block at 0x0287B520, 1 bytes long.
     Data: < > 00 
    C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\crtdbg.h(552) : {1413} normal block at 0x0287B5F0, 24 bytes long.
     Data: <  G         .   > E0 A4 47 00 01 00 00 00 20 B5 87 02 2E 00 CD CD 
    C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\crtdbg.h(552) : {1407} normal block at 0x0287B640, 8 bytes long.
     Data: <  G     > 94 A4 47 00 01 00 00 00 
    C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\crtdbg.h(552) : {1400} normal block at 0x0287B680, 24 bytes long.
     Data: <@ G             > 40 A4 47 00 01 00 00 00 00 00 00 00 00 00 00 00 
    {123} normal block at 0x02872DA0, 512 bytes long.
     Data: <                > 20 00 20 00 20 00 20 00 20 00 20 00 20 00 20 00 
    C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\crtdbg.h(552) : {110} normal block at 0x02871170, 16 bytes long.
     Data: <` G             > 60 A4 47 00 01 00 00 00 00 00 00 00 00 00 00 00 
    C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\crtdbg.h(552) : {49} normal block at 0x02871AF0, 33 bytes long.
     Data: < C              > 00 43 00 CD CD CD CD CD CD CD CD CD CD CD CD CD 
    C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\crtdbg.h(552) : {48} normal block at 0x02871B40, 40 bytes long.
     Data: <  G             > B4 A3 47 00 02 00 00 00 00 00 00 00 00 00 00 00 
    Object dump complete.
    The thing is, they all take me to this code in the crtdbg header.

    Code:
    #ifdef _CRTDBG_MAP_ALLOC
    
    inline void* __cdecl operator new(unsigned int s)
            { return ::operator new(s, _NORMAL_BLOCK, __FILE__, __LINE__); }
    
    #endif  /* _CRTDBG_MAP_ALLOC */
    Last edited by Eber Kain; 06-30-2004 at 09:06 PM.

  7. #22
    Banned
    Join Date
    May 2004
    Posts
    129
    this is a method I prefer. Whenever you screw something up in memory, it catches the error and formats and generates an error message specifically telling you where you screwed up (it does this via a messagebox with ALL of the info, and then quits the application automatically).

    Code:
    #include	<crtdbg.h> 
    
    ...
    	//This flag makes it ALWAYS check the memory heap, slows execution down, but catches errors all of the time
    	_CrtSetDbgFlag (_CRTDBG_CHECK_ALWAYS_DF );
    then, go allocate something as normal:

    Code:
    something *psomething = new something;
    _ASSERTE( _CrtCheckMemory( ) );
    very easy

  8. #23
    vae victus! skorman00's Avatar
    Join Date
    Nov 2003
    Posts
    594
    Do you have any static or global variables, or any automatic variables in main/winMain? Remember that they won't be destroyed until after the program exits, so if you're using anything from the crtdbg lib, then it will sniff them out as leaks if they have allocated any memory.

    I like Bubba's idea as well. It would let you know if it were coming from static/global variables too, since you would be explicitly destroying them. Although. it may be a pain to change your entire code base to work in that fashion.

  9. #24
    Registered User
    Join Date
    Aug 2001
    Posts
    411
    I have several classes that are global and declared dynamically. They all have delete called on them before the program exits.

    I reworked how they are declared so I know that I start the memory check before they are declared and I delete them right before calling _CrtDumpMemoryLeaks();

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. SwapBuffers & fps
    By hannibar in forum Windows Programming
    Replies: 0
    Last Post: 03-13-2006, 04:19 AM
  2. Game update...
    By jdinger in forum Game Programming
    Replies: 14
    Last Post: 11-08-2002, 06:10 AM
  3. FPS Counter Prob in OpenGL
    By brandonp in forum Game Programming
    Replies: 1
    Last Post: 07-16-2002, 02:49 PM
  4. SkyLock graphics demo (scrolling, etc.)
    By jdinger in forum Game Programming
    Replies: 9
    Last Post: 06-30-2002, 08:18 PM
  5. dramatic decrease in fps
    By DavidP in forum Game Programming
    Replies: 4
    Last Post: 06-27-2002, 09:05 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21