Ticket #7156: bufferstream_leak.cpp

File bufferstream_leak.cpp, 667 bytes (added by Jonathan Jones <jonathan.jones@…>, 10 years ago)

Very crude program which demonstrates the leak. Bufferstream types are constructed in a loop along with an int on the heap. The address of the integer advances with each iteration.

Line 
1#include <boost/interprocess/streams/bufferstream.hpp>
2#include <iostream>
3
4template<typename T>
5inline void leak_check()
6{
7 std::cout << typeid(T).name() << std::endl;
8
9 for (int ii=0; ii < 10; ++ii)
10 {
11 const std::size_t size = 80;
12 char buf[size];
13
14 T log(buf, size-1);
15 (void)log;
16
17 int* ptr = new int(0);
18 std::cout << ptr << std::endl;
19 delete ptr;
20 }
21
22 std::cout << std::endl;
23}
24
25int main()
26{
27 leak_check<boost::interprocess::ibufferstream>();
28 leak_check<boost::interprocess::obufferstream>();
29 leak_check<boost::interprocess::bufferstream>();
30}