SPrinter
64 if( sx_max_counter ) {
65 ERR_POST_X(9,
"Max memory chunks: "<< sx_max_counter);
66 ERR_POST_X(10,
"Final memory chunks: "<< sx_chunks_counter.
Get());
75 if(
value> sx_max_counter ) {
76sx_max_counter =
value;
82sx_chunks_counter.
Add(-1);
87 # define RegisterMemoryChunk(size) 88 # define DeregisterMemoryChunk(size) 92 # define ObjFatal Fatal 94 # define ObjFatal Critical 139 const SHeader* header =
reinterpret_cast<const SHeader*
>(ptr)-1;
144 "Bad chunk header magic: already freed");
148 "Bad chunk header magic");
154 "Object is beyond chunk memory");
196 char* ptr =
reinterpret_cast<char*
>(header + 1);
197 char* end = ptr +
size;
240 if( malloc_threshold == 0 ) {
244 if( malloc_threshold < min_threshold ) {
245malloc_threshold = min_threshold;
248 if( malloc_threshold > max_threshold ) {
249malloc_threshold = max_threshold;
260 for(
int i= 0;
i< 2; ++
i) {
271 "double fault in chunk allocator");
294 "cannot determine the chunk, memory will not be released");
static CObjectMemoryPoolChunk * GetChunk(const void *ptr)
CObjectMemoryPoolChunk(const CObjectMemoryPoolChunk &)
void * Allocate(size_t size)
void operator=(const CObjectMemoryPoolChunk &)
~CObjectMemoryPoolChunk(void)
CObjectMemoryPoolChunk(size_t size)
void IncrementObjectCount(void)
void DecrementObjectCount(void)
static CObjectMemoryPoolChunk * CreateChunk(size_t size)
static const int chunk_size
TNCBIAtomicValue TValue
Alias TValue for TNCBIAtomicValue.
TValue Add(int delta) THROWS_NONE
Atomically add value (=delta), and return new counter value.
TValue Get(void) const THROWS_NONE
Get atomic counter value.
#define ERR_POST_X_ONCE(err_subcode, message)
Error posting only once during program execution with default error code and given error subcode.
#define ERR_POST_X(err_subcode, message)
Error posting with default error code and given error subcode.
void Critical(CExceptionArgs_Base &args)
void * Allocate(size_t size)
Allocate memory block.
friend class CObjectMemoryPool
virtual void DoDeleteThisObject(void)
Mark this object as allocated in heap â object can be deleted.
void AddReference(void) const
Add reference to object.
void Reset(void)
Reset reference object.
CRef< CObjectMemoryPoolChunk > m_CurrentChunk
void RemoveReference(void) const
Remove reference to object.
static void Delete(const CObject *object)
Check if object is allocated from some memory pool, and delete it correspondingly.
void SetChunkSize(size_t chunk_size)
Change chunks' size.
~CObjectMemoryPool(void)
destructor
void SetMallocThreshold(size_t malloc_threshold)
Change threshold for direct allocation from system heap.
CObject(void)
Constructor.
void Deallocate(void *ptr)
Deallocate memory block.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition of all error codes used in corelib (xncbi.lib).
const struct ncbi::grid::netcache::search::fields::SIZE size
const GenericPointer< typename T::ValueType > T2 value
#define DeregisterMemoryChunk(size)
static const size_t kMinThresholdRatio
static const size_t kDefaultChunkSize
static const size_t kMinThreshold
#define RegisterMemoryChunk(size)
static const size_t kDefaultThresholdRatio
static const size_t kMinChunkSize
Memory pool for fast allocation of memory for localized set of CObjects, e.g.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4