diff --git a/service/cmemory.lua b/service/cmemory.lua index e2c1b4b1..06627ae3 100644 --- a/service/cmemory.lua +++ b/service/cmemory.lua @@ -7,4 +7,4 @@ memory.dump() print("Total memory:", memory.total()) print("Total block:", memory.block()) -skynet.exit() +skynet.start(function() skynet.exit() end) diff --git a/skynet-src/malloc_hook.c b/skynet-src/malloc_hook.c index 5ace81d5..424513c3 100644 --- a/skynet-src/malloc_hook.c +++ b/skynet-src/malloc_hook.c @@ -66,7 +66,7 @@ fill_prefix(char* ptr) { uint32_t handle = skynet_current_handle(); size_t size = je_malloc_usable_size(ptr); uint32_t *p = (uint32_t *)(ptr + size - sizeof(uint32_t)); - *p = handle; + memcpy(p, &handle, sizeof(handle)); update_xmalloc_stat_alloc(handle, size); return ptr; @@ -77,7 +77,8 @@ clean_prefix(char* ptr) { uint32_t* rawptr = (uint32_t*)ptr - 1; size_t size = je_malloc_usable_size(rawptr); uint32_t *p = (uint32_t *)(ptr + size - sizeof(uint32_t)); - uint32_t handle = *p; + uint32_t handle; + memcpy(&handle, p, sizeof(handle)); update_xmalloc_stat_free(handle, size); return ptr; }