Topic: STL map unusual behaviour


Author: slonial@yodlee.com
Date: Thu, 16 Feb 2006 09:38:55 CST
Raw View
Hi,

I am using two STL maps as data member for COM server with
VC++6.0.These two maps are unrelated in the sense that they are storing

different data.
first map is of type(6 MB in size)
std::map<long,ISumInfo*>


 and second is of type(3 MB in process)
std::map<string,list<string> >


I want to clear the first map but on clearing the map the memory
doesn't come down for process.But as soon as I clear the second map the

memory comes down is equivalent
to size of both the maps.


I am not able to understand that how two maps are related.
For clearing the first map I have released the IsumInfo objects and
destructors are getting invoked properly for clearing the map I have
tried calling
three ways but the result is same.
//m_siteDB.clear();


//m_siteDB.erase(m_siteDB.begin(), m_siteDB.end());


//std::map<long,ISumInfo*>().swap(m_siteDB);


If somebody have faced this issue,Please let me know


Thanx
Sumit

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: none@here.com (Kaba)
Date: Thu, 16 Feb 2006 17:33:32 GMT
Raw View
> If somebody have faced this issue,Please let me know

This is probably a bit off-topic here. A better newsgroup:
comp.os.ms-windows.programmer.win32

Anyway, you are using COM and thus you are probably using maps across
dlls. Combining this with Visual Studio 6, I think you have the problem
of the map template instantiating itself into several modules with class
variables.

Follow this link to this problem and its solution:

http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B172396

--
Kalle Rutanen
http://kaba.hilvi.org

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: petebecker@acm.org (Pete Becker)
Date: Thu, 16 Feb 2006 18:43:55 GMT
Raw View
slonial@yodlee.com wrote:
>
> I want to clear the first map but on clearing the map the memory
> doesn't come down for process.But as soon as I clear the second map the
>
> memory comes down is equivalent
> to size of both the maps.
>

The memory used by a process is only loosely related to the memory used
by your data structures. Often the memory manager holds on to memory
that has been freed, so that it can be reused. Your code isn't using it,
but it still belongs to the process.

--

Pete Becker
Roundhouse Consulting, Ltd.

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]