[K/N] Track current heap size ^KT-55364
This commit is contained in:
committed by
Space Cloud
parent
18b6351d5d
commit
cb7698a8c2
@@ -12,13 +12,15 @@ namespace kotlin {
|
||||
|
||||
void initObjectPool() noexcept;
|
||||
void* allocateInObjectPool(size_t size) noexcept;
|
||||
void freeInObjectPool(void* ptr) noexcept;
|
||||
void freeInObjectPool(void* ptr, size_t size) noexcept;
|
||||
// Instruct the allocator to free unused resources.
|
||||
void compactObjectPoolInCurrentThread() noexcept;
|
||||
// Platform dependent. Schedule `compactObjectPoolInCurrentThread` on the main thread.
|
||||
// May do nothing if the main thread is not an event loop.
|
||||
void compactObjectPoolInMainThread() noexcept;
|
||||
|
||||
size_t allocatedBytes() noexcept;
|
||||
|
||||
template <typename T>
|
||||
struct ObjectPoolAllocator {
|
||||
using value_type = T;
|
||||
@@ -36,7 +38,7 @@ struct ObjectPoolAllocator {
|
||||
|
||||
T* allocate(std::size_t n) noexcept { return static_cast<T*>(allocateInObjectPool(n * sizeof(T))); }
|
||||
|
||||
void deallocate(T* p, std::size_t n) noexcept { freeInObjectPool(p); }
|
||||
void deallocate(T* p, std::size_t n) noexcept { freeInObjectPool(p, n * sizeof(T)); }
|
||||
};
|
||||
|
||||
template <typename T, typename U>
|
||||
|
||||
Reference in New Issue
Block a user