test-client-godot/modules/networkconnection/check_memory.cpp

40 lines
1.5 KiB
C++
Raw Normal View History

2020-03-03 21:45:30 +00:00
/*
Check Memory
Copyright (C) 2019 AleaJactaEst
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "check_memory.h"
#include "core/os/os.h"
uint64_t memstaticold = 0;
uint64_t memdynamicold = 0;
uint64_t mempeakold = 0;
void show_memory_usage()
{
uint64_t memstatic = OS::get_singleton()->get_static_memory_usage();
uint64_t memdynamic = OS::get_singleton()->get_dynamic_memory_usage();
uint64_t mempeak = OS::get_singleton()->get_static_memory_peak_usage();
OS::get_singleton()->print("[%s:%d] Usage Memory - Current [Static:%ld, Dynamic:%ld, Peak:%ld] Delta [Static:%ld, Dynamic:%ld, Peak:%ld]\n",
__FILE__, __LINE__,
memstatic, memdynamic, mempeak,
memstatic - memstaticold, memdynamic - memdynamicold, mempeak - mempeakold);
memstaticold = memstatic;
memdynamicold = memdynamic;
mempeakold = mempeak;
}