c0e18cf71091e50b00b22028ec82f648200285b1
[junction.git] / samples / MallocTest / MallocTest.cpp
1 /*------------------------------------------------------------------------
2   Junction: Concurrent data structures in C++
3   Copyright (c) 2016 Jeff Preshing
4
5   Distributed under the Simplified BSD License.
6   Original location: https://github.com/preshing/junction
7
8   This software is distributed WITHOUT ANY WARRANTY; without even the
9   implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10   See the LICENSE file for more information.
11 ------------------------------------------------------------------------*/
12
13 #include <junction/Core.h>
14 #include <turf/Heap.h>
15 #include <junction/extra/MapAdapter.h>
16 #include <iostream>
17
18 using namespace turf::intTypes;
19
20 int main() {
21     junction::extra::MapAdapter adapter(1);
22     junction::extra::MapAdapter::ThreadContext context(adapter, 0);
23     junction::extra::MapAdapter::Map map(65536);
24
25     ureg population = 0;
26     for (ureg i = 0; i < 100; i++) {
27 #if TURF_USE_DLMALLOC && TURF_DLMALLOC_FAST_STATS
28         std::cout << "Population=" << population << ", inUse=" << TURF_HEAP.getInUseBytes() << std::endl;
29 #endif
30         for (; population < i * 5000; population++)
31             map.assign(population + 1, (void*) ((population << 2) | 3));
32     }
33
34     return 0;
35 }