|
Boost-Commit : |
From: xushiweizh_at_[hidden]
Date: 2008-04-30 04:50:17
Author: xushiwei
Date: 2008-04-30 04:50:16 EDT (Wed, 30 Apr 2008)
New Revision: 44922
URL: http://svn.boost.org/trac/boost/changeset/44922
Log:
a gc_alloc example.
Text files modified:
sandbox/memory/libs/memory/test/memory/simple_examples.cpp | 19 ++++++++++++++++---
1 files changed, 16 insertions(+), 3 deletions(-)
Modified: sandbox/memory/libs/memory/test/memory/simple_examples.cpp
==============================================================================
--- sandbox/memory/libs/memory/test/memory/simple_examples.cpp (original)
+++ sandbox/memory/libs/memory/test/memory/simple_examples.cpp 2008-04-30 04:50:16 EDT (Wed, 30 Apr 2008)
@@ -60,22 +60,35 @@
void testGCAlloc()
{
boost::gc_alloc alloc;
- // same as: boost::scoped_alloc(boost::tls_block_pool::instance());
+ // same as: boost::gc_alloc(boost::tls_block_pool::instance());
int* intObj = BOOST_NEW(alloc, int);
int* intObjWithArg = BOOST_NEW(alloc, int)(10);
- int* intArray = BOOST_NEW_ARRAY(alloc, int, 100);
+ int* intArray = BOOST_NEW_ARRAY(alloc, int, 10000); // > BlockSize
int* intBuf = BOOST_ALLOC(alloc, int);
int* intArrayBuf = BOOST_ALLOC_ARRAY(alloc, int, 100);
+
+ char* hugeBuf = BOOST_NEW_ARRAY(alloc, char, boost::policy::sys::AllocSizeHuge); // > HugeSize
boost::gc_alloc* suballoc = BOOST_NEW(alloc, boost::gc_alloc);
int* e = BOOST_NEW(*suballoc, int);
+
+ boost::gc_alloc* allocArray = BOOST_NEW_ARRAY(alloc, boost::gc_alloc, 10);
+
+ alloc.destroyArray(intArray, 10000);
+ alloc.destroyArray(allocArray, 10);
+
+ for (int i = 0; i < 1000; ++i)
+ BOOST_NEW_ARRAY(alloc, int, 100);
+
+ boost::gc_alloc alloc2;
+ alloc.swap(alloc2);
}
void simpleExamples()
{
boost::enableMemoryLeakCheck();
-// _CrtSetBreakAlloc(55);
+// _CrtSetBreakAlloc(51);
// testAutoAlloc();
// testScopedAlloc();
// testTlsScopedAlloc();
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk