Loading...
Searching...
No Matches
estimateSize.h File Reference
+ Include dependency graph for estimateSize.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

template<typename T >
size_t VdfEstimateSize (const T &)
 Estimate the memory footprint of instance t of type T.
 
template<typename T , uint32_t N>
size_t VdfEstimateSize (const TfSmallVector< T, N > &v)
 Overload for TfSmallVector<T, N>
 
template<typename T , typename A >
size_t VdfEstimateSize (const std::vector< T, A > &v)
 Overload for std::vector<T>
 
template<typename T >
size_t VdfEstimateSize (const std::shared_ptr< T > &p)
 Overload for std::shared_ptr<T>
 

Function Documentation

◆ VdfEstimateSize() [1/4]

size_t VdfEstimateSize ( const std::shared_ptr< T > &  p)
inline

Overload for std::shared_ptr<T>

Definition at line 93 of file estimateSize.h.

◆ VdfEstimateSize() [2/4]

size_t VdfEstimateSize ( const std::vector< T, A > &  v)
inline

Overload for std::vector<T>

Definition at line 79 of file estimateSize.h.

◆ VdfEstimateSize() [3/4]

size_t VdfEstimateSize ( const T &  )
inline

Estimate the memory footprint of instance t of type T.

This function estimates the memory footprint of an instance of type T. Internally this is used to total up cache sizes, and give the system an opportunity to limit the memory used for execution caches.

By default, this function invokes the sizeof() operator for type T. The returned value is not a good estimate of the true memory footprint, if instances of T allocate heap memory.

Plugin writers can overload (not specialize) VdfEstimateSize for their own types in order to provide a better estimate. Note that in order for ADL to be guaranteed to find the new overload, the pattern is to declare it as an inline friend within the namespace of the class itself. Further, not polluting the unqualified namespace with these overloads also results in more succinct compiler errors if overload resolution were to fail.

Please follow the pattern established in this example:

struct MyType {
uint8_t *data;
size_t numData;
friend size_t
VdfEstimateSize(const MyType &t)
{
return sizeof(MyTpe) + (sizeof(uint8_t) * t.numData);
}
};
size_t VdfEstimateSize(const T &)
Estimate the memory footprint of instance t of type T.
Definition: estimateSize.h:55

Definition at line 55 of file estimateSize.h.

◆ VdfEstimateSize() [4/4]

size_t VdfEstimateSize ( const TfSmallVector< T, N > &  v)
inline

Overload for TfSmallVector<T, N>

Definition at line 64 of file estimateSize.h.