Re: memory size allocated by new
On Mar 6, 11:04 pm, adrian.hawry...@gmail.com wrote:
<headerFile>
/************************************************************
* Written by Adrian Hawryluk (C) Mar 6, 2007
* ----------------------------------------------------------
* You may use and add to this free of charge, but
* please keep this header intact, and if you modify
* please share your mods with everyone else.
*
* Usage:
*
* int * integer = alloc<int>::newObj();
* cout << allocBase::totalBytesAllocated() << endl; // 4
* int * intArray = alloc<int>::newObjArray(20);
* cout << allocBase::totalBytesAllocated() << endl; // 80
*
* class foo {
* int bar;
* public: ~foo() {}
* };
*
* foo * fooArray = alloc<foo>::newObjArray(20);
* cout << allocBase::totalBytesAllocated() << endl; // 84?
*
************************************************************/
This should read:
/************************************************************
* Written by Adrian Hawryluk (C) Mar 6, 2007
* ----------------------------------------------------------
* You may use and add to this free of charge, but
* please keep this header intact, and if you modify
* please share your mods with everyone else.
*
* Usage:
*
* int * integer = alloc<int>::newObj();
* cout << allocBase::totalBytesAllocated() << endl; // 4
* int * intArray = alloc<int>::newObjArray(20);
* cout << allocBase::totalBytesAllocated() << endl; // 84 (80 + 4)
*
* class foo {
* int bar;
* public: ~foo() {}
* };
*
* foo * fooArray = alloc<foo>::newObjArray(20);
* cout << allocBase::totalBytesAllocated() << endl; // 168? (84? +
84)?
*
************************************************************/
Adrian