Code:
~/test/mapTest>valgrind --leak-check=full --show-reachable=yes ./a.out
==23489== Memcheck, a memory error detector.
==23489== Copyright (C) 2002-2006, and GNU GPL'd, by Julian Seward et al.
==23489== Using LibVEX rev 1658, a library for dynamic binary translation.
==23489== Copyright (C) 2004-2006, and GNU GPL'd, by OpenWorks LLP.
==23489== Using valgrind-3.2.1, a dynamic binary instrumentation framework.
==23489== Copyright (C) 2000-2006, and GNU GPL'd, by Julian Seward et al.
==23489== For more details, rerun with: -v
==23489==
created stuff
Erasing:1
==23489== Invalid read of size 8
==23489== at 0x30F8264BE0: std::_Rb_tree_increment(std::_Rb_tree_node_base*) (in /usr/lib64/libstdc++.so.6.0.8)
==23489== by 0x402519: std::_Rb_tree_iterator<std::pair<int const, char*> >::operator++(int) (in /home/user/test/mapTest/a.out)
==23489== by 0x400F37: ClassRoom::~ClassRoom() (in /home/user/test/mapTest/a.out)
==23489== by 0x401313: main (in /home/user/test/mapTest/a.out)
==23489== Address 0x4C360F0 is 24 bytes inside a block of size 48 free'd
==23489== at 0x4A05130: operator delete(void*) (vg_replace_malloc.c:244)
==23489== by 0x402264: __gnu_cxx::new_allocator<std::_Rb_tree_node<std::pair<int const, char*> > >::deallocate(std::_Rb_tree_node<std::pair<int const, char*> >*, unsigned long) (in /home/user/test/mapTest/a.out)
==23489== by 0x40228C: std::_Rb_tree<int, std::pair<int const, char*>, std::_Select1st<std::pair<int const, char*> >, std::less<int>, std::allocator<std::pair<int const, char*> > >::_M_put_node(std::_Rb_tree_node<std::pair<int const, char*> >*) (in /home/user/test/mapTest/a.out)
==23489== by 0x4022D7: std::_Rb_tree<int, std::pair<int const, char*>, std::_Select1st<std::pair<int const, char*> >, std::less<int>, std::allocator<std::pair<int const, char*> > >::destroy_node(std::_Rb_tree_node<std::pair<int const, char*> >*) (in /home/user/test/mapTest/a.out)
==23489== by 0x402445: std::_Rb_tree<int, std::pair<int const, char*>, std::_Select1st<std::pair<int const, char*> >, std::less<int>, std::allocator<std::pair<int const, char*> > >::erase(std::_Rb_tree_iterator<std::pair<int const, char*> >) (in /home/user/test/mapTest/a.out)
==23489== by 0x402478: std::map<int, char*, std::less<int>, std::allocator<std::pair<int const, char*> > >::erase(std::_Rb_tree_iterator<std::pair<int const, char*> >) (in /home/user/test/mapTest/a.out)
==23489== by 0x400F29: ClassRoom::~ClassRoom() (in /home/user/test/mapTest/a.out)
==23489== by 0x401313: main (in /home/user/test/mapTest/a.out)
==23489==
==23489== Invalid read of size 8
==23489== at 0x30F8264C01: std::_Rb_tree_increment(std::_Rb_tree_node_base*) (in /usr/lib64/libstdc++.so.6.0.8)
==23489== by 0x402519: std::_Rb_tree_iterator<std::pair<int const, char*> >::operator++(int) (in /home/user/test/mapTest/a.out)
==23489== by 0x400F37: ClassRoom::~ClassRoom() (in /home/user/test/mapTest/a.out)
==23489== by 0x401313: main (in /home/user/test/mapTest/a.out)
==23489== Address 0x4C360E0 is 8 bytes inside a block of size 48 free'd
==23489== at 0x4A05130: operator delete(void*) (vg_replace_malloc.c:244)
==23489== by 0x402264: __gnu_cxx::new_allocator<std::_Rb_tree_node<std::pair<int const, char*> > >::deallocate(std::_Rb_tree_node<std::pair<int const, char*> >*, unsigned long) (in /home/user/test/mapTest/a.out)
==23489== by 0x40228C: std::_Rb_tree<int, std::pair<int const, char*>, std::_Select1st<std::pair<int const, char*> >, std::less<int>, std::allocator<std::pair<int const, char*> > >::_M_put_node(std::_Rb_tree_node<std::pair<int const, char*> >*) (in /home/user/test/mapTest/a.out)
==23489== by 0x4022D7: std::_Rb_tree<int, std::pair<int const, char*>, std::_Select1st<std::pair<int const, char*> >, std::less<int>, std::allocator<std::pair<int const, char*> > >::destroy_node(std::_Rb_tree_node<std::pair<int const, char*> >*) (in /home/user/test/mapTest/a.out)
==23489== by 0x402445: std::_Rb_tree<int, std::pair<int const, char*>, std::_Select1st<std::pair<int const, char*> >, std::less<int>, std::allocator<std::pair<int const, char*> > >::erase(std::_Rb_tree_iterator<std::pair<int const, char*> >) (in /home/user/test/mapTest/a.out)
==23489== by 0x402478: std::map<int, char*, std::less<int>, std::allocator<std::pair<int const, char*> > >::erase(std::_Rb_tree_iterator<std::pair<int const, char*> >) (in /home/user/test/mapTest/a.out)
==23489== by 0x400F29: ClassRoom::~ClassRoom() (in /home/user/test/mapTest/a.out)
==23489== by 0x401313: main (in /home/user/test/mapTest/a.out)
==23489==
==23489== Invalid read of size 8
==23489== at 0x30F8264C22: std::_Rb_tree_increment(std::_Rb_tree_node_base*) (in /usr/lib64/libstdc++.so.6.0.8)
==23489== by 0x402519: std::_Rb_tree_iterator<std::pair<int const, char*> >::operator++(int) (in /home/user/test/mapTest/a.out)
==23489== by 0x400F37: ClassRoom::~ClassRoom() (in /home/user/test/mapTest/a.out)
==23489== by 0x401313: main (in /home/user/test/mapTest/a.out)
==23489== Address 0x4C360F0 is 24 bytes inside a block of size 48 free'd
==23489== at 0x4A05130: operator delete(void*) (vg_replace_malloc.c:244)
==23489== by 0x402264: __gnu_cxx::new_allocator<std::_Rb_tree_node<std::pair<int const, char*> > >::deallocate(std::_Rb_tree_node<std::pair<int const, char*> >*, unsigned long) (in /home/user/test/mapTest/a.out)
==23489== by 0x40228C: std::_Rb_tree<int, std::pair<int const, char*>, std::_Select1st<std::pair<int const, char*> >, std::less<int>, std::allocator<std::pair<int const, char*> > >::_M_put_node(std::_Rb_tree_node<std::pair<int const, char*> >*) (in /home/user/test/mapTest/a.out)
==23489== by 0x4022D7: std::_Rb_tree<int, std::pair<int const, char*>, std::_Select1st<std::pair<int const, char*> >, std::less<int>, std::allocator<std::pair<int const, char*> > >::destroy_node(std::_Rb_tree_node<std::pair<int const, char*> >*) (in /home/user/test/mapTest/a.out)
==23489== by 0x402445: std::_Rb_tree<int, std::pair<int const, char*>, std::_Select1st<std::pair<int const, char*> >, std::less<int>, std::allocator<std::pair<int const, char*> > >::erase(std::_Rb_tree_iterator<std::pair<int const, char*> >) (in /home/user/test/mapTest/a.out)
==23489== by 0x402478: std::map<int, char*, std::less<int>, std::allocator<std::pair<int const, char*> > >::erase(std::_Rb_tree_iterator<std::pair<int const, char*> >) (in /home/user/test/mapTest/a.out)
==23489== by 0x400F29: ClassRoom::~ClassRoom() (in /home/user/test/mapTest/a.out)
==23489== by 0x401313: main (in /home/user/test/mapTest/a.out)
Erasing:4
Erasing:76
Erasing:79
all gone!
==23489==
==23489== ERROR SUMMARY: 10 errors from 3 contexts (suppressed: 4 from 1)
==23489== malloc/free: in use at exit: 0 bytes in 0 blocks.
==23489== malloc/free: 9 allocs, 9 frees, 345 bytes allocated.
==23489== For counts of detected errors, rerun with: -v
==23489== All heap blocks were freed -- no leaks are possible.
~/test/mapTest>