diff options
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp index 1e43d76..cb6d753 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -17,6 +17,11 @@ along with Minitrem. If not, see <http://www.gnu.org/licenses/>. #include "common.hpp" #include <chrono> +#ifdef CONFIG_SHOW_RSS +#include <sys/types.h> +#include <unistd.h> +#include <fstream> +#endif bool debug_draw_cmodels = false; bool debug_draw_paths = false; @@ -85,6 +90,28 @@ float freq_counter_t::freq_ma(void) freq_counter_t fc_render = freq_counter_t(20); freq_counter_t fc_game = freq_counter_t(10); +#ifdef CONFIG_SHOW_RSS +size_t sys_get_rss(void) +{ + std::ifstream file; + pid_t pid; + std::string line; + size_t res = 0; + + pid = getpid(); + + file.open("/proc/" + std::to_string(pid) + "/status"); + while (file >> line) { + if (line == "VmRSS:") { + file >> res; + break; + } + } + + return res * 1024; +} +#endif + int main() { nclock_ref = nclock() - 1; @@ -117,6 +144,8 @@ int main() if (!window.isOpen()) break; + sys_get_rss(); + window.clear(); render.begin_frame(now, dt); render.render(&game); |