Fix issue tracking memory allocations of more than 2GB at a time on 64-bit systems
This commit is contained in:
parent
e3c0d4ba68
commit
3b17e8fff1
|
|
@ -26,7 +26,7 @@
|
|||
////////////////////////////////////////////////////////////////////
|
||||
class EXPCL_DTOOL AtomicAdjustGccImpl {
|
||||
public:
|
||||
#if __GCC_ATOMIC_LONG_LOCK_FREE > __GCC_ATOMIC_INT_LOCK_FREE
|
||||
#if __GCC_ATOMIC_LONG_LOCK_FREE >= __GCC_ATOMIC_INT_LOCK_FREE
|
||||
// If the long can be more lock-free than int, use it instead.
|
||||
typedef __attribute__ ((aligned (__SIZEOF_LONG__))) long Integer;
|
||||
#else
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ allocate(TYPENAME pallocator_array<Type>::size_type n, TYPENAME allocator<void>:
|
|||
size_t alloc_size = n * sizeof(Type);
|
||||
// We also need to store the total number of bytes we allocated.
|
||||
alloc_size += header_reserved_bytes;
|
||||
_type_handle.inc_memory_usage(TypeHandle::MC_array, (int)alloc_size);
|
||||
_type_handle.inc_memory_usage(TypeHandle::MC_array, alloc_size);
|
||||
void *ptr = (TYPENAME pallocator_array<Type>::pointer)PANDA_MALLOC_ARRAY(alloc_size);
|
||||
*((size_t *)ptr) = alloc_size;
|
||||
return (TYPENAME pallocator_array<Type>::pointer)(((char *)ptr) + header_reserved_bytes);
|
||||
|
|
@ -69,7 +69,7 @@ deallocate(TYPENAME pallocator_array<Type>::pointer p, TYPENAME pallocator_array
|
|||
const size_t header_reserved_bytes = MemoryHook::get_header_reserved_bytes();
|
||||
void *ptr = (void *)((char *)p - header_reserved_bytes);
|
||||
size_t alloc_size = *((size_t *)ptr);
|
||||
_type_handle.dec_memory_usage(TypeHandle::MC_array, (int)alloc_size);
|
||||
_type_handle.dec_memory_usage(TypeHandle::MC_array, alloc_size);
|
||||
PANDA_FREE_ARRAY(ptr);
|
||||
#else
|
||||
free(p);
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ get_memory_usage(MemoryClass memory_class) const {
|
|||
// allocated memory for objects of this type.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void TypeHandle::
|
||||
inc_memory_usage(MemoryClass memory_class, int size) {
|
||||
inc_memory_usage(MemoryClass memory_class, size_t size) {
|
||||
assert((int)memory_class >= 0 && (int)memory_class < (int)MC_limit);
|
||||
if ((*this) != TypeHandle::none()) {
|
||||
TypeRegistryNode *rnode = TypeRegistry::ptr()->look_up(*this, NULL);
|
||||
|
|
@ -72,7 +72,7 @@ inc_memory_usage(MemoryClass memory_class, int size) {
|
|||
// the total allocated memory for objects of this type.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void TypeHandle::
|
||||
dec_memory_usage(MemoryClass memory_class, int size) {
|
||||
dec_memory_usage(MemoryClass memory_class, size_t size) {
|
||||
assert((int)memory_class >= 0 && (int)memory_class < (int)MC_limit);
|
||||
if ((*this) != TypeHandle::none()) {
|
||||
TypeRegistryNode *rnode = TypeRegistry::ptr()->look_up(*this, NULL);
|
||||
|
|
|
|||
|
|
@ -125,12 +125,12 @@ PUBLISHED:
|
|||
|
||||
#ifdef DO_MEMORY_USAGE
|
||||
int get_memory_usage(MemoryClass memory_class) const;
|
||||
void inc_memory_usage(MemoryClass memory_class, int size);
|
||||
void dec_memory_usage(MemoryClass memory_class, int size);
|
||||
void inc_memory_usage(MemoryClass memory_class, size_t size);
|
||||
void dec_memory_usage(MemoryClass memory_class, size_t size);
|
||||
#else
|
||||
static CONSTEXPR int get_memory_usage(MemoryClass) { return 0; }
|
||||
INLINE void inc_memory_usage(MemoryClass, int) { }
|
||||
INLINE void dec_memory_usage(MemoryClass, int) { }
|
||||
INLINE void inc_memory_usage(MemoryClass, size_t) { }
|
||||
INLINE void dec_memory_usage(MemoryClass, size_t) { }
|
||||
#endif // DO_MEMORY_USAGE
|
||||
|
||||
INLINE int get_index() const;
|
||||
|
|
|
|||
Loading…
Reference in New Issue