Click here to Skip to main content
15,881,938 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
GeneralRe: Keep program open and running Pin
Lucidation9-Oct-12 11:14
Lucidation9-Oct-12 11:14 
GeneralRe: Keep program open and running Pin
Richard MacCutchan9-Oct-12 11:19
mveRichard MacCutchan9-Oct-12 11:19 
AnswerRe: Keep program open and running Pin
Stephen Hewitt11-Oct-12 21:45
Stephen Hewitt11-Oct-12 21:45 
QuestionUSBView Compile Error Pin
Jim Fell5-Oct-12 10:17
Jim Fell5-Oct-12 10:17 
AnswerRe: USBView Compile Error Pin
Wes Aday5-Oct-12 10:33
professionalWes Aday5-Oct-12 10:33 
GeneralRe: USBView Compile Error Pin
Jim Fell10-Oct-12 8:04
Jim Fell10-Oct-12 8:04 
QuestionFree memory allocated by std::multimap Pin
MrKBA4-Oct-12 2:41
MrKBA4-Oct-12 2:41 
AnswerRe: Free memory allocated by std::multimap Pin
pasztorpisti6-Oct-12 15:26
pasztorpisti6-Oct-12 15:26 
It might depend on the implementation of the multimap. I checked it long ago but if I remember right your erase() call sets back the allocation to a minimum, identical to the allocation performed by the default ctor of multimap (at least in the SGI stl implementation of Visual C++ I used at the time). Note that even newly created empty std containers have a small piece of memory preallocated and some containers (like std::vector) dont shrink the size of the allocated memory area (capacity) even if you erase items.

A trick that seems to reset the allocated memory of any std containers regardless of stl implementation and container type is the following:
C++
typedef std::multimap<int,int> MyMap;
MyMap global_map;

void my_func()
{
    // We create a new map instance and we swap its contents with the other "big" container instance.
    // This swap operation replaces the pointers inside the two containers so after the swap() the
    // global_map contains the small newly allocated blocks, and empty_map contains the big mem blocks
    // previously owned by global_map. Note: when empty_map runs out of scope it releases the big block.
    // This trick works with other stl container types too.
    MyMap empty_map;
    empty_map.swap(global_map);
}

AnswerRe: Free memory allocated by std::multimap Pin
Stephen Hewitt11-Oct-12 21:53
Stephen Hewitt11-Oct-12 21:53 
GeneralRe: Free memory allocated by std::multimap Pin
pasztorpisti11-Oct-12 22:53
pasztorpisti11-Oct-12 22:53 
Questionhow to import COM interface methods in Win32 dll? Pin
litu kumar30-Sep-12 19:58
litu kumar30-Sep-12 19:58 
AnswerRe: how to import COM interface methods in Win32 dll? Pin
«_Superman_»1-Oct-12 21:29
professional«_Superman_»1-Oct-12 21:29 
GeneralOff topic Pin
Richard MacCutchan2-Oct-12 2:55
mveRichard MacCutchan2-Oct-12 2:55 
GeneralRe: Off topic Pin
«_Superman_»2-Oct-12 3:00
professional«_Superman_»2-Oct-12 3:00 
GeneralRe: Off topic Pin
Richard MacCutchan2-Oct-12 3:23
mveRichard MacCutchan2-Oct-12 3:23 
QuestionTooltip for ATL toolbar Pin
Sakhalean24-Sep-12 18:43
Sakhalean24-Sep-12 18:43 
QuestionCAsyncSocket Send( arguments ) Pin
bkelly1318-Sep-12 16:13
bkelly1318-Sep-12 16:13 
AnswerRe: CAsyncSocket Send( arguments ) Pin
Richard MacCutchan18-Sep-12 21:50
mveRichard MacCutchan18-Sep-12 21:50 
GeneralRe: CAsyncSocket Send( arguments ) Pin
bkelly1319-Sep-12 12:13
bkelly1319-Sep-12 12:13 
AnswerRe: CAsyncSocket Send( arguments ) Pin
pasztorpisti29-Sep-12 23:52
pasztorpisti29-Sep-12 23:52 
GeneralRe: CAsyncSocket Send( arguments ) Pin
Richard MacCutchan30-Sep-12 1:07
mveRichard MacCutchan30-Sep-12 1:07 
GeneralRe: CAsyncSocket Send( arguments ) Pin
pasztorpisti30-Sep-12 3:16
pasztorpisti30-Sep-12 3:16 
GeneralRe: CAsyncSocket Send( arguments ) Pin
Richard MacCutchan30-Sep-12 4:00
mveRichard MacCutchan30-Sep-12 4:00 
GeneralRe: CAsyncSocket Send( arguments ) Pin
pasztorpisti30-Sep-12 4:07
pasztorpisti30-Sep-12 4:07 
GeneralRe: CAsyncSocket Send( arguments ) Pin
pasztorpisti30-Sep-12 4:03
pasztorpisti30-Sep-12 4:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.