Commit cee2d843 authored by nanahira's avatar nanahira

Merge branch 'patch-memtrack' of github.com:Fluorohydride/ygopro-core into develop

parents 31ef3c26 9198f9e4
...@@ -35,7 +35,7 @@ void* LuaMemTracker::AllocThunk(void* ud, void* ptr, size_t osize, size_t nsize) ...@@ -35,7 +35,7 @@ void* LuaMemTracker::AllocThunk(void* ud, void* ptr, size_t osize, size_t nsize)
void* LuaMemTracker::Alloc(void* ptr, size_t osize, size_t nsize) { void* LuaMemTracker::Alloc(void* ptr, size_t osize, size_t nsize) {
if (nsize == 0) { if (nsize == 0) {
if (ptr && osize <= total_allocated) { if (ptr) {
total_allocated -= osize; total_allocated -= osize;
} }
return real_alloc(real_ud, ptr, osize, nsize); return real_alloc(real_ud, ptr, osize, nsize);
...@@ -75,6 +75,6 @@ void LuaMemTracker::write_log() { ...@@ -75,6 +75,6 @@ void LuaMemTracker::write_log() {
std::fprintf(log_file, "%s | used = %zu bytes | max_used = %zu bytes | limit = unlimited\n", std::fprintf(log_file, "%s | used = %zu bytes | max_used = %zu bytes | limit = unlimited\n",
time_buf, total_allocated, max_used); time_buf, total_allocated, max_used);
std::fflush(log_file); // 确保实时写入磁盘 std::fflush(log_file); // make it write instantly
} }
#endif #endif
...@@ -48,6 +48,7 @@ public: ...@@ -48,6 +48,7 @@ public:
char msgbuf[64]; char msgbuf[64];
lua_State* lua_state; lua_State* lua_state;
lua_State* current_state; lua_State* current_state;
LuaMemTracker* mem_tracker;
param_list params; param_list params;
param_list resumes; param_list resumes;
coroutine_map coroutines; coroutine_map coroutines;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment