test_msvc_mem_leak_detect.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /* Copyright (C) 2011 Kwan Ting Chan
  2. *
  3. * Use, modification and distribution is subject to the
  4. * Boost Software License, Version 1.0. (See accompanying
  5. * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
  6. */
  7. // Test of bug #4346 (https://svn.boost.org/trac/boost/ticket/4346)
  8. #ifdef _MSC_VER
  9. #define _CRTDBG_MAP_ALLOC
  10. #include <stdlib.h>
  11. #include <crtdbg.h>
  12. #endif
  13. #include <boost/pool/poolfwd.hpp>
  14. #include <boost/pool/simple_segregated_storage.hpp>
  15. #include <boost/pool/pool.hpp>
  16. #include <boost/pool/pool_alloc.hpp>
  17. #include <boost/pool/singleton_pool.hpp>
  18. #include <boost/pool/object_pool.hpp>
  19. #include <vector>
  20. struct Foo {};
  21. int main()
  22. {
  23. {
  24. boost::pool<> p(sizeof(int));
  25. (p.malloc)();
  26. }
  27. {
  28. boost::object_pool<Foo> p;
  29. (p.malloc)();
  30. }
  31. {
  32. (boost::singleton_pool<Foo, sizeof(int)>::malloc)();
  33. }
  34. boost::singleton_pool<Foo, sizeof(int)>::purge_memory();
  35. {
  36. std::vector<int, boost::pool_allocator<int> > v;
  37. v.push_back(8);
  38. }
  39. boost::singleton_pool<boost::pool_allocator_tag,
  40. sizeof(int)>::release_memory();
  41. }