"Fake" memory leak about stl::map on windows server 2008. RRS feed

  • Question

  •  Hi guys,

     IF I post this in a wrong forum, please help redirect me to where I should be.

    we encountered a memory leak issue when test our applications on windows server 2008. and after several days' investigation we narrowed down to stl::map.

    our simiple code as following:

    typedef vector<BYTE> VECBYTE;
    typedef map<int, VECBYTE> MAPINTVEC;
    MAPINTVEC g_map;

    void CTestBoostDlg::OnBnClickedButton1()

     VECBYTE attrBlob;

     for( int i=0; i<10000; ++i )
             attrBlob.resize( 10000 );
             g_map.insert( MAPINTVEC::value_type(i, attrBlob) );

    void CTestBoostDlg::OnBnClickedButton3()


    and when we click button1 there will be about 100MB data insert into g_map. then we click button 3 will clear the map.

    different behaviours on different win os:

    win 2003/xp: work as we want, all memory were released.

    win 2008: 1st btn1 clikced:  100MB memory burst.

                        btn3 clicked: about 99mb released.

                        btn1 clicked: abuot 99mb allocated.

                        btn3 clicked: about 98mb released.


                       after many cycles:

                       btn1 clicked: abuot several kbs allocated.

                       btn3 clicked: about several kbs  released.

        we want to know why this behaviour happen on win2008. and better there was a way to REAL release that 100MB memory, because that g_map was nerver uesed after somehours running.



    One world, one dream
    Wednesday, February 23, 2011 6:20 AM