src/memusage.h
/** Compute the memory used for dynamically allocated but owned data structures.
 *  For generic data types, this is *not* recursive. DynamicUsage(vector<vector<int> >)
 *  will compute the memory used for the vector<int>'s, but not for the ints inside.
 *  This is for efficiency reasons, as these functions are intended to be fast. If
 *  application data structures require more accurate inner accounting, they should
 *  iterate themselves, or use more efficient caching + updating on modification.
 */
Compute the memory used for dynamically allocated but owned data structures.
For generic data types, this is *not* recursive. DynamicUsage(vector >)
will compute the memory used for the vector's, but not for the ints inside.
This is for efficiency reasons, as these functions are intended to be fast. If
application data structures require more accurate inner accounting, they should
iterate themselves, or use more efficient caching + updating on modification.
Compute the memory used for dynamically allocated but owned data structures . For generic data types this is * not * recursive . DynamicUsage ( vector > ) will compute the memory used for the vector ' s but not for the ints inside . This is for efficiency reasons as these functions are intended to be fast . If application data structures require more accurate inner accounting they should iterate themselves or use more efficient caching + updating on modification .
static inline size_t MallocUsage(size_t alloc)
{
    if (alloc == 0) {
        return 0;
    } else if (sizeof(void*) == 8) {
        return ((alloc + 31) >> 4) << 4;
    } else if (sizeof(void*) == 4) {
        return ((alloc + 15) >> 3) << 3;
    } else {
        assert(0);
    }
}
static inline size_t MallocUsage ( size_t alloc ) { if ( alloc == 0 ) { return 0 ; } else if ( sizeof ( void * ) == 8 ) { return ( ( alloc + 31 ) >> 4 ) << 4 ; } else if ( sizeof ( void * ) == 4 ) { return ( ( alloc + 15 ) >> 3 ) << 3 ; } else { assert ( 0 ) ; } }
Compute the memory used for dynamically allocated but owned data structures.
Compute the memory used for dynamically allocated but owned data structures .