Memory leaks

43 views
Skip to first unread message

David Connet

unread,
Oct 14, 2023, 11:46:08 AM10/14/23
to wx-...@googlegroups.com
Before I write up a bug, I wanted to check if I'm missing something...

Upgrading from 3.2.2.1 to 3.2.3 has suddenly developed a large memory
leak (VS2022) on exit (my program exits cleanly on 3.2.2.1). Looking at
the allocations, they appear to be coming via wxTranslations. I say
"appear to" as I also see leaks in wxStrings that are in wxPlatformInfo.
(I haven't investigated all the leaks I see, nor have have I tried this
with the samples)

I'm just wondering if there's some additional cleanup step that is now
required that I missed.

Dave

David Connet

unread,
Oct 14, 2023, 11:52:25 AM10/14/23
to wx-...@googlegroups.com
Just compiled the internat sample, and the memory leak occurs there too.
(and not in 3.2.2.1) I simply compiled (using nmake) the debug version
and had the utility dbgview running. 3.2.2.1 had no leaks. 3.2.3 has:
[24540] Detected memory leaks!
[24540] Dumping objects ->
[24540] {80927}
[24540] normal block at 0x00000291687EFAF0, 32 bytes long.
[24540]  Data: <t o m o r r o w > 74 00 6F 00 6D 00 6F 00 72 00 72 00 6F
00 77 00
[24540] {80926}
[24540] normal block at 0x0000029166DA04B0, 16 bytes long.
[24540]  Data: <`t h            > 60 74 7F 68 91 02 00 00 00 00 00 00 00
00 00 00
[24540] {80925}
[24540] normal block at 0x00000291687F7450, 72 bytes long.
[24540]  Data: <p  f     r h    > 70 12 D4 66 91 02 00 00 10 72 7F 68 91
02 00 00
[24540] {80891}
[24540] normal block at 0x00000291687EF850, 32 bytes long.
[24540]  Data: <y e s t e r d a > 79 00 65 00 73 00 74 00 65 00 72 00 64
00 61 00
[24540] {80890}
[24540] normal block at 0x0000029166DA0500, 16 bytes long.
[24540]  Data: < n h            > C0 6E 7F 68 91 02 00 00 00 00 00 00 00
00 00 00
[24540] {80889}
[24540] normal block at 0x00000291687F6EB0, 72 bytes long.
[24540]  Data: <0  h       h    > 30 B5 B4 68 91 02 00 00 D0 C3 B4 68 91
02 00 00
[24540] {80856}
[24540] normal block at 0x0000029166DA1310, 16 bytes long.
[24540]  Data: < r h            > 20 72 7F 68 91 02 00 00 00 00 00 00 00
00 00 00
[24540] {80855}
[24540] normal block at 0x00000291687F7210, 72 bytes long.
[24540]  Data: <Pt h    @H f    > 50 74 7F 68 91 02 00 00 40 48 DB 66 91
02 00 00
[24540] {71808}
[24540] normal block at 0x0000029168B44460, 96 bytes long.
[24540]  Data: <N u m b e r   i > 4E 00 75 00 6D 00 62 00 65 00 72 00 20
00 69 00
[24540] {71807}
[24540] normal block at 0x0000029166D9F9C0, 16 bytes long.
[24540]  Data: <PH f            > 50 48 DB 66 91 02 00 00 00 00 00 00 00
00 00 00
[24540] {71806}
[24540] normal block at 0x0000029166DB4840, 72 bytes long.
[24540]  Data: < r h     Y f    > 10 72 7F 68 91 02 00 00 20 59 DB 66 91
02 00 00
[24540] {71664}
[24540] normal block at 0x0000029166D9ECA0, 16 bytes long.
[24540]  Data: <0Y f            > 30 59 DB 66 91 02 00 00 00 00 00 00 00
00 00 00
[24540] {71663}
[24540] normal block at 0x0000029166DB5920, 72 bytes long.
[24540]  Data: <@H f       h    > 40 48 DB 66 91 02 00 00 E0 BF B4 68 91
02 00 00
[24540] {71569}
[24540] normal block at 0x0000029166D9E250, 16 bytes long.
[24540]  Data: <0G f            > 30 47 DB 66 91 02 00 00 00 00 00 00 00
00 00 00
[24540] {71568}
[24540] normal block at 0x0000029166DB4720, 72 bytes long.
[24540]  Data: <   h    p  h    > D0 C3 B4 68 91 02 00 00 70 B7 B4 68 91
02 00 00
[24540] {62409}
[24540] normal block at 0x00000291687DF860, 32 bytes long.
[24540]  Data: <N u m e r i c   > 4E 00 75 00 6D 00 65 00 72 00 69 00 63
00 20 00
[24540] {62408}
[24540] normal block at 0x00000291688124D0, 16 bytes long.
[24540]  Data: <   h            > F0 BF B4 68 91 02 00 00 00 00 00 00 00
00 00 00
[24540] {62407}
[24540] normal block at 0x0000029168B4BFE0, 72 bytes long.
[24540]  Data: < Y f    P  h    > 20 59 DB 66 91 02 00 00 50 B6 B4 68 91
02 00 00
[24540] {61816}
[24540] normal block at 0x0000029168B4CCD0, 80 bytes long.
[24540]  Data: <. . .   a n d   > 2E 00 2E 00 2E 00 20 00 61 00 6E 00 64
00 20 00
[24540] {61815}
[24540] normal block at 0x0000029168812520, 16 bytes long.
[24540]  Data: <`  h            > 60 B6 B4 68 91 02 00 00 00 00 00 00 00
00 00 00
[24540] {61814}
[24540] normal block at 0x0000029168B4B650, 72 bytes long.
[24540]  Data: <   h    P  h    > E0 BF B4 68 91 02 00 00 50 BF B4 68 91
02 00 00
[24540] {61222}
[24540] normal block at 0x0000029166D887A0, 64 bytes long.
[24540]  Data: <U I   l o c a l > 55 00 49 00 20 00 6C 00 6F 00 63 00 61
00 6C 00
[24540] {61221}
[24540] normal block at 0x0000029168811C10, 16 bytes long.
[24540]  Data: <`  h            > 60 BF B4 68 91 02 00 00 00 00 00 00 00
00 00 00
[24540] {61220}
[24540] normal block at 0x0000029168B4BF50, 72 bytes long.
[24540]  Data: <P  h    @  h    > 50 B6 B4 68 91 02 00 00 40 CC B4 68 91
02 00 00
[24540] {60622}
[24540] normal block at 0x0000029168B4CD60, 80 bytes long.
[24540]  Data: <C u r r e n t   > 43 00 75 00 72 00 72 00 65 00 6E 00 74
00 20 00
[24540] {60621}
[24540] normal block at 0x0000029168811DA0, 16 bytes long.
[24540]  Data: <P  h            > 50 CC B4 68 91 02 00 00 00 00 00 00 00
00 00 00
[24540] {60620}
[24540] normal block at 0x0000029168B4CC40, 72 bytes long.
[24540]  Data: <P  h       h    > 50 BF B4 68 91 02 00 00 00 CA B4 68 91
02 00 00
[24540] {58015}
[24540] normal block at 0x0000029168810950, 16 bytes long.
[24540]  Data: <   h            > 10 CA B4 68 91 02 00 00 00 00 00 00 00
00 00 00
[24540] {58014}
[24540] normal block at 0x0000029168B4CA00, 72 bytes long.
[24540]  Data: <@  h    p  h    > 40 CC B4 68 91 02 00 00 70 C9 B4 68 91
02 00 00
[24540] {57963}
[24540] normal block at 0x0000029168811260, 16 bytes long.
[24540]  Data: <   h            > A0 CA B4 68 91 02 00 00 00 00 00 00 00
00 00 00
[24540] {57962}
[24540] normal block at 0x0000029168B4CA90, 72 bytes long.
[24540]  Data: <   h       h    > A0 B4 B4 68 91 02 00 00 20 B9 B4 68 91
02 00 00
[24540] {57931}
[24540] normal block at 0x0000029168810F40, 16 bytes long.
[24540]  Data: <   h            > 80 C9 B4 68 91 02 00 00 00 00 00 00 00
00 00 00
[24540] {57930}
[24540] normal block at 0x0000029168B4C970, 72 bytes long.
[24540]  Data: <   h    @  h    > 00 CA B4 68 91 02 00 00 40 C3 B4 68 91
02 00 00
[24540] {57898}
[24540] normal block at 0x0000029168810DB0, 16 bytes long.
[24540]  Data: <P  h            > 50 C3 B4 68 91 02 00 00 00 00 00 00 00
00 00 00
[24540] {57897}
[24540] normal block at 0x0000029168B4C340, 72 bytes long.
[24540]  Data: <p  h    @  h    > 70 C9 B4 68 91 02 00 00 40 BA B4 68 91
02 00 00
[24540] {57792}
[24540] normal block at 0x00000291687D5640, 48 bytes long.
[24540]  Data: <S h o w   a b o > 53 00 68 00 6F 00 77 00 20 00 61 00 62
00 6F 00
[24540] {57791}
[24540] normal block at 0x0000029168811210, 16 bytes long.
[24540]  Data: <@  h            > 40 D0 B4 68 91 02 00 00 00 00 00 00 00
00 00 00
[24540] {57790}
[24540] normal block at 0x0000029168B4D030, 72 bytes long.
[24540]  Data: <@  h       h    > 40 BA B4 68 91 02 00 00 D0 BA B4 68 91
02 00 00
[24540] {57753}
[24540] normal block at 0x0000029168810E50, 16 bytes long.
[24540]  Data: <P  h            > 50 BA B4 68 91 02 00 00 00 00 00 00 00
00 00 00
[24540] {57752}
[24540] normal block at 0x0000029168B4BA40, 72 bytes long.
[24540]  Data: <@  h    0  h    > 40 C3 B4 68 91 02 00 00 30 D0 B4 68 91
02 00 00
[24540] {57411}
[24540] normal block at 0x0000029168810130, 16 bytes long.
[24540]  Data: <   h            > E0 B1 B4 68 91 02 00 00 00 00 00 00 00
00 00 00
[24540] {57410}
[24540] normal block at 0x0000029168B4B1D0, 72 bytes long.
[24540]  Data: <   h    p  f    > E0 C8 B4 68 91 02 00 00 70 12 D4 66 91
02 00 00
[24540] {57355}
[24540] normal block at 0x000002916880F2D0, 16 bytes long.
[24540]  Data: <   h            > E0 BA B4 68 91 02 00 00 00 00 00 00 00
00 00 00
[24540] {57354}
[24540] normal block at 0x0000029168B4BAD0, 72 bytes long.
[24540]  Data: <0  h       h    > 30 D0 B4 68 91 02 00 00 90 C1 B4 68 91
02 00 00
[24540] {57181}
[24540] normal block at 0x000002916880FA50, 16 bytes long.
[24540]  Data: <   h            > F0 C8 B4 68 91 02 00 00 00 00 00 00 00
00 00 00
[24540] {57180}
[24540] normal block at 0x0000029168B4C8E0, 72 bytes long.
[24540]  Data: < K f       h    > 10 4B DB 66 91 02 00 00 D0 B1 B4 68 91
02 00 00
[24540] {57131}
[24540] normal block at 0x00000291687D55D0, 48 bytes long.
[24540]  Data: <& M e s s a g e > 26 00 4D 00 65 00 73 00 73 00 61 00 67
00 65 00
[24540] {57130}
[24540] normal block at 0x00000291688104A0, 16 bytes long.
[24540]  Data: <   h            > A0 C1 B4 68 91 02 00 00 00 00 00 00 00
00 00 00
[24540] {57129}
[24540] normal block at 0x0000029168B4C190, 72 bytes long.
[24540]  Data: <   h       h    > D0 BA B4 68 91 02 00 00 80 CE B4 68 91
02 00 00
[24540] {57097}
[24540] normal block at 0x0000029168B446E0, 96 bytes long.
[24540]  Data: <T e s t s   m e > 54 00 65 00 73 00 74 00 73 00 20 00 6D
00 65 00
[24540] {57096}
[24540] normal block at 0x000002916880EA60, 16 bytes long.
[24540]  Data: <   h            > D0 B5 B4 68 91 02 00 00 00 00 00 00 00
00 00 00
[24540] {57095}
[24540] normal block at 0x0000029168B4B5C0, 72 bytes long.
[24540]  Data: <   f     K f    > 90 1C D4 66 91 02 00 00 10 4B DB 66 91
02 00 00
[24540] {57050}
[24540] normal block at 0x0000029166D85420, 64 bytes long.
[24540]  Data: <& 3   w x T R A > 26 00 33 00 20 00 77 00 78 00 54 00 52
00 41 00
[24540] {57049}
[24540] normal block at 0x000002916880F910, 16 bytes long.
[24540]  Data: <   h            > 90 CE B4 68 91 02 00 00 00 00 00 00 00
00 00 00
[24540] {57048}
[24540] normal block at 0x0000029168B4CE80, 72 bytes long.
[24540]  Data: <   h       h    > 90 C1 B4 68 91 02 00 00 20 CB B4 68 91
02 00 00
[24540] {57016}
[24540] normal block at 0x0000029166D853A0, 64 bytes long.
[24540]  Data: <T e s t s   t h > 54 00 65 00 73 00 74 00 73 00 20 00 74
00 68 00
[24540] {57015}
[24540] normal block at 0x000002916880E1A0, 16 bytes long.
[24540]  Data: <0  h            > 30 C2 B4 68 91 02 00 00 00 00 00 00 00
00 00 00
[24540] {57014}
[24540] normal block at 0x0000029168B4C220, 72 bytes long.
[24540]  Data: <   h     a f    > F0 CD B4 68 91 02 00 00 00 61 DB 66 91
02 00 00
[24540] {56969}
[24540] normal block at 0x00000291687D6FA0, 48 bytes long.
[24540]  Data: <& 2   _ N ( )   > 26 00 32 00 20 00 5F 00 4E 00 28 00 29
00 20 00
[24540] {56968}
[24540] normal block at 0x000002916880ECE0, 16 bytes long.
[24540]  Data: <0  h            > 30 CB B4 68 91 02 00 00 00 00 00 00 00
00 00 00
[24540] {56967}
[24540] normal block at 0x0000029168B4CB20, 72 bytes long.
[24540]  Data: <   h    0  h    > 80 CE B4 68 91 02 00 00 30 B5 B4 68 91
02 00 00
[24540] {56935}
[24540] normal block at 0x00000291687D6280, 48 bytes long.
[24540]  Data: <T e s t s   t h > 54 00 65 00 73 00 74 00 73 00 20 00 74
00 68 00
[24540] {56934}
[24540] normal block at 0x000002916880EE20, 16 bytes long.
[24540]  Data: <   h            > C0 B9 B4 68 91 02 00 00 00 00 00 00 00
00 00 00
[24540] {56933}
[24540] normal block at 0x0000029168B4B9B0, 72 bytes long.
[24540]  Data: < P f     ! f    > 20 50 DB 66 91 02 00 00 A0 21 D4 66 91
02 00 00
[24540] {56888}
[24540] normal block at 0x00000291687D5870, 48 bytes long.
[24540]  Data: <& 1   _ ( )   ( > 26 00 31 00 20 00 5F 00 28 00 29 00 20
00 28 00
[24540] {56887}
[24540] normal block at 0x000002916880EB00, 16 bytes long.
[24540]  Data: <@  h            > 40 B5 B4 68 91 02 00 00 00 00 00 00 00
00 00 00
[24540] {56886}
[24540] normal block at 0x0000029168B4B530, 72 bytes long.
[24540]  Data: <   h     n h    > 20 CB B4 68 91 02 00 00 B0 6E 7F 68 91
02 00 00
[24540] {56854}
[24540] normal block at 0x00000291687D60C0, 48 bytes long.
[24540]  Data: <T e s t s   t h > 54 00 65 00 73 00 74 00 73 00 20 00 74
00 68 00
[24540] {56853}
[24540] normal block at 0x000002916880E5B0, 16 bytes long.
[24540]  Data: <`  h            > 60 C8 B4 68 91 02 00 00 00 00 00 00 00
00 00 00
[24540] {56852}
[24540] normal block at 0x0000029168B4C850, 72 bytes long.
[24540]  Data: <   h    `[ f    > F0 B2 B4 68 91 02 00 00 60 5B DB 66 91
02 00 00
[24540] {56799}
[24540] normal block at 0x00000291687DF260, 32 bytes long.
[24540]  Data: <& P l a y   a   > 26 00 50 00 6C 00 61 00 79 00 20 00 61
00 20 00
[24540] {56798}
[24540] normal block at 0x000002916880DF70, 16 bytes long.
[24540]  Data: <   h            > E0 C3 B4 68 91 02 00 00 00 00 00 00 00
00 00 00
[24540] {56797}
[24540] normal block at 0x0000029168B4C3D0, 72 bytes long.
[24540]  Data: < n h     G f    > B0 6E 7F 68 91 02 00 00 20 47 DB 66 91
02 00 00
[24540] {56765}
[24540] normal block at 0x0000029168AE1680, 112 bytes long.
[24540]  Data: <A   l i t t l e > 41 00 20 00 6C 00 69 00 74 00 74 00 6C
00 65 00
[24540] {56764}
[24540] normal block at 0x000002916880F0A0, 16 bytes long.
[24540]  Data: <   h            > 80 B7 B4 68 91 02 00 00 00 00 00 00 00
00 00 00
[24540] {56763}
[24540] normal block at 0x0000029168B4B770, 72 bytes long.
[24540]  Data: < G f       h    > 20 47 DB 66 91 02 00 00 A0 B4 B4 68 91
02 00 00
[24540] {56718}
[24540] normal block at 0x00000291687D6D70, 48 bytes long.
[24540]  Data: <& S a v e   d u > 26 00 53 00 61 00 76 00 65 00 20 00 64
00 75 00
[24540] {56717}
[24540] normal block at 0x000002916880DE80, 16 bytes long.
[24540]  Data: <   h            > D0 C7 B4 68 91 02 00 00 00 00 00 00 00
00 00 00
[24540] {56716}
[24540] normal block at 0x0000029168B4C7C0, 72 bytes long.
[24540]  Data: <   h       h    > C0 BE B4 68 91 02 00 00 10 C6 B4 68 91
02 00 00
[24540] {56684}
[24540] normal block at 0x0000029168B4C730, 80 bytes long.
[24540]  Data: <S h o w s   a   > 53 00 68 00 6F 00 77 00 73 00 20 00 61
00 20 00
[24540] {56683}
[24540] normal block at 0x000002916880E240, 16 bytes long.
[24540]  Data: <   h            > B0 B4 B4 68 91 02 00 00 00 00 00 00 00
00 00 00
[24540] {56682}
[24540] normal block at 0x0000029168B4B4A0, 72 bytes long.
[24540]  Data: <p  h       h    > 70 B7 B4 68 91 02 00 00 90 CA B4 68 91
02 00 00
[24540] {56637}
[24540] normal block at 0x00000291687D6440, 48 bytes long.
[24540]  Data: <& O p e n   b o > 26 00 4F 00 70 00 65 00 6E 00 20 00 62
00 6F 00
[24540] {56636}
[24540] normal block at 0x000002916880E2E0, 16 bytes long.
[24540]  Data: <0  h            > 30 B9 B4 68 91 02 00 00 00 00 00 00 00
00 00 00
[24540] {56635}
[24540] normal block at 0x0000029168B4B920, 72 bytes long.
[24540]  Data: <   h       h    > 90 CA B4 68 91 02 00 00 C0 BE B4 68 91
02 00 00
[24540] {56603}
[24540] normal block at 0x0000029168B450E0, 96 bytes long.
[24540]  Data: <S h o w s   a   > 53 00 68 00 6F 00 77 00 73 00 20 00 61
00 20 00
[24540] {56602}
[24540] normal block at 0x000002916880E4C0, 16 bytes long.
[24540]  Data: <   h            > D0 BE B4 68 91 02 00 00 00 00 00 00 00
00 00 00
[24540] {56601}
[24540] normal block at 0x0000029168B4BEC0, 72 bytes long.
[24540]  Data: <   h       h    > 20 B9 B4 68 91 02 00 00 C0 C7 B4 68 91
02 00 00
[24540] {56557}
[24540] normal block at 0x00000291687D6210, 48 bytes long.
[24540]  Data: <Q u i t   t h i > 51 00 75 00 69 00 74 00 20 00 74 00 68
00 69 00
[24540] {56556}
[24540] normal block at 0x000002916880EE70, 16 bytes long.
[24540]  Data: <   h            > 00 CE B4 68 91 02 00 00 00 00 00 00 00
00 00 00
[24540] {56555}
[24540] normal block at 0x0000029168B4CDF0, 72 bytes long.
[24540]  Data: <P  f       h    > 50 1A D4 66 91 02 00 00 20 C2 B4 68 91
02 00 00
[24540] {56518}
[24540] normal block at 0x000002916880DFC0, 16 bytes long.
[24540]  Data: <   h            > 20 C6 B4 68 91 02 00 00 00 00 00 00 00
00 00 00
[24540] {56517}
[24540] normal block at 0x0000029168B4C610, 72 bytes long.
[24540]  Data: <   h       h    > C0 C7 B4 68 91 02 00 00 10 B4 B4 68 91
02 00 00
[24540] {56459}
[24540] normal block at 0x0000029168B4CF10, 80 bytes long.
[24540]  Data: <& T e s t   l o > 26 00 54 00 65 00 73 00 74 00 20 00 6C
00 6F 00
[24540] {56458}
[24540] normal block at 0x000002916880E7E0, 16 bytes long.
[24540]  Data: <   h            > 20 B4 B4 68 91 02 00 00 00 00 00 00 00
00 00 00
[24540] {56457}
[24540] normal block at 0x0000029168B4B410, 72 bytes long.
[24540]  Data: <   h       h    > 10 C6 B4 68 91 02 00 00 F0 B2 B4 68 91
02 00 00
[24540] {55899}
[24540] normal block at 0x0000029166D87020, 64 bytes long.
[24540]  Data: <I n t e r n a t > 49 00 6E 00 74 00 65 00 72 00 6E 00 61
00 74 00
[24540] {55898}
[24540] normal block at 0x000002916880CB20, 16 bytes long.
[24540]  Data: <   h            > 00 B3 B4 68 91 02 00 00 00 00 00 00 00
00 00 00
[24540] {55897}
[24540] normal block at 0x0000029168B4B2F0, 72 bytes long.
[24540]  Data: <   h    P  h    > 10 B4 B4 68 91 02 00 00 50 C8 B4 68 91
02 00 00
[24540] {40588}
[24540] normal block at 0x0000029166DB8820, 1024 bytes long.
[24540]  Data: <   h       h    > 00 CA B4 68 91 02 00 00 00 CA B4 68 91
02 00 00
[24540] {40587}
[24540] normal block at 0x000002916880B950, 16 bytes long.
[24540]  Data: <p[ f            > 70 5B DB 66 91 02 00 00 00 00 00 00 00
00 00 00
[24540] {40586}
[24540] normal block at 0x0000029166DB5B60, 72 bytes long.
[24540]  Data: <P  h    0L f    > 50 C8 B4 68 91 02 00 00 30 4C DB 66 91
02 00 00
[24540] {40578}
[24540] normal block at 0x000002916880BF90, 16 bytes long.
[24540]  Data: <@L f            > 40 4C DB 66 91 02 00 00 00 00 00 00 00
00 00 00
[24540] {40577}
[24540] normal block at 0x0000029166DB4C30, 72 bytes long.
[24540]  Data: <`[ f    P  f    > 60 5B DB 66 91 02 00 00 50 1A D4 66 91
02 00 00
[24540] {40569}
[24540] normal block at 0x000002916880C210, 16 bytes long.
[24540]  Data: < K f            > 20 4B DB 66 91 02 00 00 00 00 00 00 00
00 00 00
[24540] {40568}
[24540] normal block at 0x0000029166DB4B10, 72 bytes long.
[24540]  Data: <   h       h    > C0 B5 B4 68 91 02 00 00 E0 C8 B4 68 91
02 00 00
[24540] {40560}
[24540] normal block at 0x000002916880BE00, 16 bytes long.
[24540]  Data: <0P f            > 30 50 DB 66 91 02 00 00 00 00 00 00 00
00 00 00
[24540] {40559}
[24540] normal block at 0x0000029166DB5020, 72 bytes long.
[24540]  Data: < a f       h    > 00 61 DB 66 91 02 00 00 B0 B9 B4 68 91
02 00 00
[24540] {40551}
[24540] normal block at 0x000002916880B9A0, 16 bytes long.
[24540]  Data: < a f            > 10 61 DB 66 91 02 00 00 00 00 00 00 00
00 00 00
[24540] {40550}
[24540] normal block at 0x0000029166DB6100, 72 bytes long.
[24540]  Data: <   h     P f    > 20 C2 B4 68 91 02 00 00 20 50 DB 66 91
02 00 00
[24540] {6607}
[24540] normal block at 0x0000029166D441E0, 64 bytes long.
[24540]  Data: <g e n e r a t e > 67 00 65 00 6E 00 65 00 72 00 61 00 74
00 65 00
[24540] {6606}
[24540] normal block at 0x0000029166D46510, 16 bytes long.
[24540]  Data: <`  f            > 60 1A D4 66 91 02 00 00 00 00 00 00 00
00 00 00
[24540] {6605}
[24540] normal block at 0x0000029166D41A50, 72 bytes long.
[24540]  Data: <0L f       h    > 30 4C DB 66 91 02 00 00 F0 CD B4 68 91
02 00 00
[24540] {6581}
[24540] normal block at 0x0000029166D3EA10, 48 bytes long.
[24540]  Data: <s h o w   t h i > 73 00 68 00 6F 00 77 00 20 00 74 00 68
00 69 00
[24540] {6580}
[24540] normal block at 0x0000029166D47640, 16 bytes long.
[24540]  Data: <   f            > A0 1C D4 66 91 02 00 00 00 00 00 00 00
00 00 00
[24540] {6579}
[24540] normal block at 0x0000029166D41C90, 72 bytes long.
[24540]  Data: < , f       h    > E0 2C D4 66 91 02 00 00 C0 B5 B4 68 91
02 00 00
[24540] {6552}
[24540] normal block at 0x0000029166D42230, 80 bytes long.
[24540]  Data: <d o   s e t   l > 64 00 6F 00 20 00 73 00 65 00 74 00 20
00 6C 00
[24540] {6551}
[24540] normal block at 0x0000029166D466F0, 16 bytes long.
[24540]  Data: < ! f            > B0 21 D4 66 91 02 00 00 00 00 00 00 00
00 00 00
[24540] {6550}
[24540] normal block at 0x0000029166D421A0, 72 bytes long.
[24540]  Data: <   h     , f    > B0 B9 B4 68 91 02 00 00 E0 2C D4 66 91
02 00 00
[24540] {6523}
[24540] normal block at 0x0000029166D44CE0, 64 bytes long.
[24540]  Data: <s k i p   s e t > 73 00 6B 00 69 00 70 00 20 00 73 00 65
00 74 00
[24540] {6522}
[24540] normal block at 0x0000029166D47050, 16 bytes long.
[24540]  Data: < , f            > F0 2C D4 66 91 02 00 00 00 00 00 00 00
00 00 00
[24540] {6521}
[24540] normal block at 0x0000029166D42CE0, 72 bytes long.
[24540]  Data: < ! f       f    > A0 21 D4 66 91 02 00 00 90 1C D4 66 91
02 00 00
[24540] {6519}
[24540] normal block at 0x0000029166D1E4C0, 16 bytes long.
[24540]  Data: <p  f            > 70 F2 D3 66 91 02 00 00 00 00 00 00 00
00 00 00
[24540] {6518}
[24540] normal block at 0x0000029166D41270, 72 bytes long.
[24540]  Data: <   h    Pt h    > D0 B1 B4 68 91 02 00 00 50 74 7F 68 91
02 00 00
[24540] {6517}
[24540] normal block at 0x0000029166D32E50, 16 bytes long.
[24540]  Data: <X  f            > 58 F2 D3 66 91 02 00 00 00 00 00 00 00
00 00 00
[24540] {6516}
[24540] normal block at 0x0000029166D3F240, 96 bytes long.
[24540]  Data: <                > 00 00 00 00 00 00 00 00 00 CD CD CD CD
CD CD CD
[24540] Object dump complete.

Vadim Zeitlin

unread,
Oct 14, 2023, 4:34:43 PM10/14/23
to wx-...@googlegroups.com
On Sat, 14 Oct 2023 08:46:05 -0700 David Connet wrote:

DC> Before I write up a bug, I wanted to check if I'm missing something...
DC>
DC> Upgrading from 3.2.2.1 to 3.2.3 has suddenly developed a large memory
DC> leak (VS2022) on exit (my program exits cleanly on 3.2.2.1). Looking at
DC> the allocations, they appear to be coming via wxTranslations.

I don't see any changes doing any allocations in wxTranslations itself,
but maybe this was broken by some broader wxLocale changes...

More surprisingly, I don't see any leaks in the internat sample neither,
at least not in debug x64 build (also using MSVS 2022). I have no idea
what's going on here, but could it be related to using some non-default
wx build options?

In any case, if you could please debug it as explained e.g. here:

https://learn.microsoft.com/en-us/troubleshoot/developer/visualstudio/cpp/libraries/use-rtbreakalloc-debug-memory-allocation

it would be very useful.

TIA!
VZ

utelle

unread,
Oct 14, 2023, 6:46:54 PM10/14/23
to wx-dev
Vadim Zeitlin schrieb am Samstag, 14. Oktober 2023 um 22:34:43 UTC+2:
On Sat, 14 Oct 2023 08:46:05 -0700 David Connet wrote:

DC> Before I write up a bug, I wanted to check if I'm missing something...
DC>
DC> Upgrading from 3.2.2.1 to 3.2.3 has suddenly developed a large memory
DC> leak (VS2022) on exit (my program exits cleanly on 3.2.2.1). Looking at
DC> the allocations, they appear to be coming via wxTranslations.

I don't see any changes doing any allocations in wxTranslations itself,
but maybe this was broken by some broader wxLocale changes...

More surprisingly, I don't see any leaks in the internat sample neither,
at least not in debug x64 build (also using MSVS 2022).

I tested with VS 2022 both x86 and x64 wxWidgets builds, but I experienced no memory leaks at all. I used the default build options.
 
I have no idea what's going on here, but could it be related to using some non-default
wx build options?

In any case, if you could please debug it as explained e.g. here:

https://learn.microsoft.com/en-us/troubleshoot/developer/visualstudio/cpp/libraries/use-rtbreakalloc-debug-memory-allocation

it would be very useful.

Personally, I use Visual Leak Detector to detect memory leaks. VLD diagnostics are usually very good and helpful.

Regards,
Ulrich

David Connet

unread,
Oct 15, 2023, 11:03:59 AM10/15/23
to wx-...@googlegroups.com
I'm compiling with:
nmake -f makefile.vc BUILD=debug  UNICODE=1 SHARED=0 RUNTIME_LIBS=static
TARGET_CPU=x64 COMPILER_PREFIX=vc143 CPPFLAGS="/DwxMSVC_VERSION_AUTO=1
/Zc:__cplusplus /std:c++17"

I've also tweaked setup.h slightly:
  - Set wxWIN_COMPATIBILITY_3_0 to 0
  - Set wxWIN_COMPATIBILITY_3_2 to 0
  - Set wxUSE_UNSAFE_WXSTRING_CONV to 0
  - Specifically set wxDEBUG_LEVEL (uncomment ifdef/define items)
  - Set wxUSER_PRIVATE_FONTS to 0 (currently 1)

I managed to coerce the internat vcproj file into 2022 and set a
breakpoint on the first allocation noted (last in the list)

>    internat.exe!heap_alloc_dbg_internal(const unsigned __int64 size,
const int block_use, const char * const file_name, const int
line_number) Line 319    C++
     internat.exe!heap_alloc_dbg(const unsigned __int64 size, const int
block_use, const char * const file_name, const int line_number) Line
450    C++
     internat.exe!_malloc_dbg(unsigned __int64 size, int block_use,
const char * file_name, int line_number) Line 496 C++
     internat.exe!malloc(unsigned __int64 size) Line 27    C++
     [External Code]
     internat.exe!wxThreadSpecificInfo::Get() Line 218    C++
     internat.exe!wxTranslations::GetUntranslatedString(const wxString
& str) Line 1605    C++
     internat.exe!wxGetTranslation(const wxString & str, const wxString
& domain, const wxString & context) Line 299 C++
     internat.exe!MyApp::OnInitCmdLine(wxCmdLineParser & parser) Line
167    C++
     internat.exe!wxAppConsoleBase::OnInit() Line 279    C++
     internat.exe!MyApp::OnInit() Line 202    C++
     internat.exe!wxAppConsoleBase::CallOnInit() Line 93    C++
     internat.exe!wxEntryReal(int & argc, wchar_t * * argv) Line 481    C++
     internat.exe!wxEntry(int & argc, wchar_t * * argv) Line 175    C++
     internat.exe!wxEntry(HINSTANCE__ * hInstance, HINSTANCE__ *
__formal, char * __formal, int nCmdShow) Line 345    C++
     internat.exe!WinMain(HINSTANCE__ * hInstance, HINSTANCE__ *
hPrevInstance, char * lpCmdLine, int nCmdShow) Line 150    C++

The last one (first in dumped list) looks different. It's just an empty
wxString that is returned.

>    internat.exe!heap_alloc_dbg_internal(const unsigned __int64 size,
const int block_use, const char * const file_name, const int
line_number) Line 319    C++
     internat.exe!heap_alloc_dbg(const unsigned __int64 size, const int
block_use, const char * const file_name, const int line_number) Line
450    C++
     internat.exe!_malloc_dbg(unsigned __int64 size, int block_use,
const char * file_name, int line_number) Line 496 C++
     internat.exe!malloc(unsigned __int64 size) Line 27    C++
     [External Code]
     internat.exe!wxString::wxString(const wxString & stringSrc) Line
1180    C++
     internat.exe!wxControlBase::Ellipsize(const wxString & label,
const wxDC & dc, wxEllipsizeMode mode, int maxFinalWidth, int flags)
Line 580    C++
     internat.exe!wxGrid::DrawTextRectangle(wxDC & dc, const wxString &
text, const wxRect & rect, const wxGridCellAttr & attr, int hAlign, int
vAlign) Line 7420    C++
     internat.exe!wxGridCellDateRenderer::Draw(wxGrid & grid,
wxGridCellAttr & attr, wxDC & dc, const wxRect & rectCell, int row, int
col, bool isSelected) Line 210    C++
     internat.exe!wxGrid::DrawCell(wxDC & dc, const wxGridCellCoords &
coords) Line 6656    C++
     internat.exe!wxGrid::DrawGridCellArea(wxDC & dc, const
wxGridCellCoordsArray & cells) Line 6590    C++
     internat.exe!wxGridWindow::OnPaint(wxPaintEvent & __formal) Line
2309    C++
     internat.exe!wxAppConsoleBase::HandleEvent(wxEvtHandler * handler,
void(wxEvtHandler::*)(wxEvent &) func, wxEvent & event) Line 662    C++
     internat.exe!wxAppConsoleBase::CallEventHandler(wxEvtHandler *
handler, wxEventFunctor & functor, wxEvent & event) Line 673    C++
     internat.exe!wxEvtHandler::ProcessEventIfMatchesId(const
wxEventTableEntryBase & entry, wxEvtHandler * handler, wxEvent & event)
Line 1432    C++
     internat.exe!wxEventHashTable::HandleEvent(wxEvent & event,
wxEvtHandler * self) Line 1039    C++
     internat.exe!wxEvtHandler::TryHereOnly(wxEvent & event) Line
1628    C++
     internat.exe!wxEvtHandler::TryBeforeAndHere(wxEvent & event) Line
4007    C++
     internat.exe!wxEvtHandler::ProcessEventLocally(wxEvent & event)
Line 1561    C++
     internat.exe!wxEvtHandler::ProcessEvent(wxEvent & event) Line
1534    C++
     internat.exe!wxEvtHandler::SafelyProcessEvent(wxEvent & event)
Line 1650    C++
     internat.exe!wxWindowBase::HandleWindowEvent(wxEvent & event) Line
1554    C++
     internat.exe!wxWindow::HandlePaint() Line 5373    C++
     internat.exe!wxWindow::MSWHandleMessage(__int64 * result, unsigned
int message, unsigned __int64 wParam, __int64 lParam) Line 3118    C++
     internat.exe!wxWindow::MSWWindowProc(unsigned int message,
unsigned __int64 wParam, __int64 lParam) Line 3906    C++
     internat.exe!wxWndProc(HWND__ * hWnd, unsigned int message,
unsigned __int64 wParam, __int64 lParam) Line 2948    C++
     [External Code]
     internat.exe!wxWindow::MSWSafeIsDialogMessage(tagMSG * msg) Line
2813    C++
     internat.exe!wxWindow::MSWProcessMessage(tagMSG * pMsg) Line
2695    C++
     internat.exe!wxGUIEventLoop::PreProcessMessage(tagMSG * msg) Line
142    C++
     internat.exe!wxGUIEventLoop::ProcessMessage(tagMSG * msg) Line
160    C++
     internat.exe!wxGUIEventLoop::Dispatch() Line 226    C++
     internat.exe!wxEventLoopManual::ProcessEvents() Line 234 C++
     internat.exe!wxEventLoopManual::DoRun() Line 288    C++
     internat.exe!wxEventLoopBase::Run() Line 87    C++
     internat.exe!wxAppConsoleBase::MainLoop() Line 381    C++
     internat.exe!wxAppConsoleBase::OnRun() Line 304    C++
     internat.exe!wxAppBase::OnRun() Line 335    C++
     internat.exe!wxEntryReal(int & argc, wchar_t * * argv) Line 497    C++
     internat.exe!wxEntry(int & argc, wchar_t * * argv) Line 175    C++
     internat.exe!wxEntry(HINSTANCE__ * hInstance, HINSTANCE__ *
__formal, char * __formal, int nCmdShow) Line 345    C++
     internat.exe!WinMain(HINSTANCE__ * hInstance, HINSTANCE__ *
hPrevInstance, char * lpCmdLine, int nCmdShow) Line 150    C++
     [External Code]

David Connet

unread,
Oct 15, 2023, 11:12:24 AM10/15/23
to wx-...@googlegroups.com
On 10/15/2023 8:03 AM, David Connet wrote:
> I'm compiling with:
> nmake -f makefile.vc BUILD=debug  UNICODE=1 SHARED=0
> RUNTIME_LIBS=static TARGET_CPU=x64 COMPILER_PREFIX=vc143
> CPPFLAGS="/DwxMSVC_VERSION_AUTO=1 /Zc:__cplusplus /std:c++17"

As an added data point - I just tried this with the current trunk (well,
I'm currently 4 commits behind HEAD) and the leaks aren't there either.
So I'm only experiencing them with the released 3.2.3 files.

Dave

David Connet

unread,
Oct 15, 2023, 11:21:53 AM10/15/23
to wx-...@googlegroups.com
I meant to say "released source files" - I never use the released binaries.

Dave

Vadim Zeitlin

unread,
Oct 15, 2023, 11:23:29 AM10/15/23
to wx-...@googlegroups.com
On Sun, 15 Oct 2023 08:03:54 -0700 David Connet wrote:

DC> I'm compiling with:
DC> nmake -f makefile.vc BUILD=debug  UNICODE=1 SHARED=0 RUNTIME_LIBS=static
DC> TARGET_CPU=x64 COMPILER_PREFIX=vc143 CPPFLAGS="/DwxMSVC_VERSION_AUTO=1
DC> /Zc:__cplusplus /std:c++17"

I don't use RUNTIME_LIBS=static but I don't see how could this change
anything here...

DC> I've also tweaked setup.h slightly:

And these options are either the same ones as I use or can't affect this.

DC> I managed to coerce the internat vcproj file into 2022 and set a
DC> breakpoint on the first allocation noted (last in the list)

Thanks, so it's a wxThreadSpecificInfo object which is getting leaked.
Looking at this code, I think I've found a bug: we don't call
wxThreadSpecificInfoTLS::CleanUp() from the main thread, but we should, so
I think we should apply this:

--------------------------------- >8 --------------------------------------
diff --git a/src/msw/thread.cpp b/src/msw/thread.cpp
index 3bd1075279..d2c0b66257 100644
--- a/src/msw/thread.cpp
+++ b/src/msw/thread.cpp
@@ -1465,6 +1465,9 @@ bool wxThreadModule::OnInit()

void wxThreadModule::OnExit()
{
+ // Delete thread-specific info object for the main thread too, if any.
+ wxThreadSpecificInfoTLS::CleanUp();
+
if ( !::TlsFree(gs_tlsThisThread) )
{
wxLogLastError(wxT("TlsFree failed."));
--------------------------------- >8 --------------------------------------

But the thing is that it shouldn't do anything anyhow because any modern
Windows system should provide FLS API and so the pointers should be freed
automatically.

Could you please check what's going on in wxThreadSpecificInfoTLS ctor on
your system? Are any functions from kernel32.dll not being found/loaded
somehow?

And, also, does applying the diff above fix the leak for you?

Thanks,
VZ

Vadim Zeitlin

unread,
Oct 15, 2023, 12:16:38 PM10/15/23
to wx-...@googlegroups.com
[I'm reply to the list as this is where you probably wanted to send your
reply anyhow]

On Sun, 15 Oct 2023 08:57:39 -0700 David Connet wrote:

DC> On 10/15/2023 8:23 AM, Vadim Zeitlin wrote:
DC> > On Sun, 15 Oct 2023 08:03:54 -0700 David Connet wrote:
DC> >
DC> > Could you please check what's going on in wxThreadSpecificInfoTLS ctor on
DC> > your system? Are any functions from kernel32.dll not being found/loaded
DC> > somehow?
DC>
DC> All 4 lookups are found. And AllocCallback returned 8.
DC>
DC> > And, also, does applying the diff above fix the leak for you?
DC>
DC> No change.

Thanks for testing. So this confirms that FLS cleanup function is not
being called, which is not especially helpful as I still have no idea why.
The documentation says that

FlsCallback is called on fiber deletion, thread exit, and when an
FLS index is freed.

(see https://learn.microsoft.com/en-us/windows/win32/api/winnt/nc-winnt-pfls_callback_function)
and so it should be called on thread exit and this is exactly what happens
to me:

internat.exe!wxThreadSpecificInfoTLS::DeleteThreadSpecificInfo(void * ptr=0x0000029372989c30)
ntdll.dll!RtlpFlsDataCleanup()
ntdll.dll!LdrShutdownProcess()
ntdll.dll!RtlExitUserProcess()
kernel32.dll!ExitProcessImplementation()
ucrtbased.dll!exit_or_terminate_process(const unsigned int return_code=0x00000000)
ucrtbased.dll!common_exit(const int return_code=0x00000000, const _crt_exit_cleanup_mode cleanup_mode=_crt_exit_full_cleanup, const _crt_exit_return_mode return_mode=_crt_exit_terminate_process)
ucrtbased.dll!exit(int return_code=0x00000000)
internat.exe!__scrt_common_main_seh()
internat.exe!__scrt_common_main()
internat.exe!WinMainCRTStartup(void * __formal=0x000000975ec12000)
kernel32.dll!BaseThreadInitThunk()
ntdll.dll!RtlUserThreadStart()

The only remaining test I can think of is to check if this is really
specific to static CRT, but I don't think it is, as it's ntdll.dll itself
which does the cleanup (as can be seen in the stack above), not the CRT.

But wait! What if DeleteThreadSpecificInfo() is called, but just too late
when using static CRT? Could you please put a breakpoint on it to
definitely determine if it is called or not?

Thanks again,
VZ

Vadim Zeitlin

unread,
Oct 15, 2023, 1:16:06 PM10/15/23
to wx-...@googlegroups.com
[replying to the list again...]

On Sun, 15 Oct 2023 09:51:03 -0700 David Connet wrote:

DC> On 10/15/2023 9:16 AM, Vadim Zeitlin wrote:
DC> > But wait! What if DeleteThreadSpecificInfo() is called, but just too late
DC> > when using static CRT? Could you please put a breakpoint on it to
DC> > definitely determine if it is called or not?
DC>
DC> Ah ha!
DC>
DC> The breakpoint hit, looked at the debug window and it has spewed the
DC> leak info.

Thanks, this solves the mystery: apparently static CRT build can't ensure
that its own callback is called after ours and so it reports the memory
freed by it as leaked.

This is annoying because it means we need to free it manually in this
case, i.e. if _DEBUG is defined but _DLL is not. I am not sure if we should
do it only in this case or just do it always to address it.

But something like this ought to address it, I think:

--------------------------------- >8 --------------------------------------
diff --git a/src/msw/thread.cpp b/src/msw/thread.cpp
index 3bd1075279..31ac8b3d58 100644
--- a/src/msw/thread.cpp
+++ b/src/msw/thread.cpp
@@ -201,7 +201,12 @@ public:

static void CleanUp()
{
+ // To avoid bogus memory leaks reports when using debug version of
+ // static MSVC CRT we need to free memory ourselves even when it would
+ // have been done by FlsAlloc() callback because it does it too late.
+#if !defined(_MSC_VER) || !defined(_DEBUG) || defined(_DLL)
if (!Instance().AllocCallback)
+#endif
{
// FLS API was not available, which means that objects will not be freed automatically.
delete Get();
@@ -1465,6 +1470,9 @@ bool wxThreadModule::OnInit()

void wxThreadModule::OnExit()
{
+ // Delete thread-specific info object for the main thread too, if any.
+ wxThreadSpecificInfoTLS::CleanUp();
+
if ( !::TlsFree(gs_tlsThisThread) )
{
wxLogLastError(wxT("TlsFree failed."));
--------------------------------- >8 --------------------------------------

DC> And thread.cpp in 3.2.2 and trunk are completely different.

Yes, master uses C++11 thread local, but in 3.2 we still support C++98.
VZ

David Connet

unread,
Oct 15, 2023, 3:20:10 PM10/15/23
to wx-...@googlegroups.com
On 10/15/2023 10:16 AM, Vadim Zeitlin wrote:
> [replying to the list again...]
Dang it! (I was wondering why I didn't see my message in the list. I've
got Ctrl+R is ingrained, and then I forget to check...
I can confirm that fixes it for me. Thx!
> DC> And thread.cpp in 3.2.2 and trunk are completely different.
>
> Yes, master uses C++11 thread local, but in 3.2 we still support C++98.
> VZ

What I meant there was not that the code was different, but that in
3.2.2 and trunk there are no leaks.

Dave

Vadim Zeitlin

unread,
Oct 15, 2023, 6:20:00 PM10/15/23
to wx-...@googlegroups.com
On Sun, 15 Oct 2023 12:20:06 -0700 David Connet wrote:

DC> I can confirm that fixes it for me. Thx!

Thanks for testing, I'll push it to 3.2 branch when I collect enough
commits for the next PR.

VZ
Reply all
Reply to author
Forward
0 new messages