QString MemoryStatistics::reportCurrent() { double GB = 1<<30; double avail = availableMemory() / GB; double current = currentMemoryUsage() / GB; return QString("Available memory: %1 GB -- Current memory usage: %2 GB (%3%)") .arg(avail, 1,'g',3) .arg(current, 1,'g',3) .arg(100*current/avail, 1,'f',1); }
QString MemoryStatistics::reportPeak() { double GB = 1<<30; double avail = availableMemory() / GB; double peak = peakMemoryUsage() / GB; return QString("Available memory: %1 GB -- Peak memory usage: %2 GB (%3%)") .arg(avail, 1,'g',3) .arg(peak, 1,'g',3) .arg(100*peak/avail, 1,'f',1); }
bool HttpServer::CanContinue(const MemInfo& mem, int64_t rssMb, int64_t rssNeeded, int cacheFreeFactor) { if (!mem.valid()) return false; if (mem.freeMb < RuntimeOption::ServerCriticalFreeMb) return false; auto const availableMb = availableMemory(mem, rssMb, cacheFreeFactor); auto const result = (rssMb + availableMb >= rssNeeded); if (result) assert(CanStep(mem, rssMb, rssNeeded, cacheFreeFactor)); return result; }
bool HttpServer::CanContinue(const MemInfo& mem, int64_t rssMb, int64_t rssNeeded, int cacheFreeFactor) { assert(CanStep(mem, rssMb, rssNeeded, cacheFreeFactor)); if (!mem.valid()) return false; // Don't proceed if free memory is too limited, no matter how big // the cache is. if (mem.freeMb < rssNeeded / 16) return false; auto const availableMb = availableMemory(mem, rssMb, cacheFreeFactor); return (rssMb + availableMb >= rssNeeded); }
bool HttpServer::CanStep(const MemInfo& mem, int64_t rssMb, int64_t rssNeeded, int cacheFreeFactor) { if (!mem.valid()) return false; if (mem.freeMb < RuntimeOption::ServerCriticalFreeMb) return false; auto const availableMb = availableMemory(mem, rssMb, cacheFreeFactor); // Estimation of the memory needed till the next check point. Since // the current check point is not the last one, we try to be more // optimistic, by assuming that memory requirement won't grow // drastically between successive check points, and that it won't // grow over our estimate. auto const neededToStep = std::min(rssNeeded / 4, rssNeeded - rssMb); return (availableMb >= neededToStep); }
void menuStatisticsDebug(uint8_t event) { TITLE(STR_MENUDEBUG); #if defined(WATCHDOG_TEST) if (warningResult) { warningResult = 0; // do a user requested watchdog test TRACE("Performing watchdog test"); pausePulses(); } #endif switch(event) { case EVT_KEY_LONG(KEY_ENTER): g_eeGeneral.mAhUsed = 0; g_eeGeneral.globalTimer = 0; eeDirty(EE_GENERAL); sessionTimer = 0; killEvents(event); AUDIO_KEYPAD_UP(); break; case EVT_KEY_FIRST(KEY_ENTER): #if defined(LUA) maxLuaInterval = 0; maxLuaDuration = 0; #endif maxMixerDuration = 0; AUDIO_KEYPAD_UP(); break; #if defined(DEBUG_TRACE_BUFFER) case EVT_KEY_FIRST(KEY_UP): pushMenu(menuTraceBuffer); return; #endif case EVT_KEY_FIRST(KEY_DOWN): chainMenu(menuStatisticsView); break; case EVT_KEY_FIRST(KEY_EXIT): chainMenu(menuMainView); break; #if defined(WATCHDOG_TEST) case EVT_KEY_LONG(KEY_MENU): { POPUP_CONFIRMATION("Test the watchdog?"); const char * w = "The radio will reset!"; SET_WARNING_INFO(w, strlen(w), 0); } break; #endif } lcd_putsLeft(MENU_DEBUG_Y_FREE_RAM, "Free Mem"); lcd_outdezAtt(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_FREE_RAM, availableMemory(), LEFT); lcd_puts(lcdLastPos, MENU_DEBUG_Y_FREE_RAM, "b"); #if defined(LUA) lcd_putsLeft(MENU_DEBUG_Y_LUA, "Lua scripts"); lcd_putsAtt(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_LUA+1, "[Duration]", SMLSIZE); lcd_outdezAtt(lcdLastPos, MENU_DEBUG_Y_LUA, 10*maxLuaDuration, LEFT); lcd_putsAtt(lcdLastPos+2, MENU_DEBUG_Y_LUA+1, "[Interval]", SMLSIZE); lcd_outdezAtt(lcdLastPos, MENU_DEBUG_Y_LUA, 10*maxLuaInterval, LEFT); #endif lcd_putsLeft(MENU_DEBUG_Y_MIXMAX, STR_TMIXMAXMS); lcd_outdezAtt(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_MIXMAX, DURATION_MS_PREC2(maxMixerDuration), PREC2|LEFT); lcd_puts(lcdLastPos, MENU_DEBUG_Y_MIXMAX, "ms"); #if defined(USB_SERIAL) lcd_putsLeft(MENU_DEBUG_Y_USB, "Usb"); lcd_outdezAtt(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_USB, charsWritten, LEFT); lcd_puts(lcdLastPos, MENU_DEBUG_Y_USB, " "); lcd_outdezAtt(lcdLastPos, MENU_DEBUG_Y_USB, APP_Rx_ptr_in, LEFT); lcd_puts(lcdLastPos, MENU_DEBUG_Y_USB, " "); lcd_outdezAtt(lcdLastPos, MENU_DEBUG_Y_USB, usbWraps, LEFT); #endif lcd_putsLeft(MENU_DEBUG_Y_RTOS, STR_FREESTACKMINB); lcd_putsAtt(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_RTOS+1, "[M]", SMLSIZE); lcd_outdezAtt(lcdLastPos, MENU_DEBUG_Y_RTOS, menusStack.available(), UNSIGN|LEFT); lcd_putsAtt(lcdLastPos+2, MENU_DEBUG_Y_RTOS+1, "[X]", SMLSIZE); lcd_outdezAtt(lcdLastPos, MENU_DEBUG_Y_RTOS, mixerStack.available(), UNSIGN|LEFT); lcd_putsAtt(lcdLastPos+2, MENU_DEBUG_Y_RTOS+1, "[A]", SMLSIZE); lcd_outdezAtt(lcdLastPos, MENU_DEBUG_Y_RTOS, audioStack.available(), UNSIGN|LEFT); lcd_putsAtt(lcdLastPos+2, MENU_DEBUG_Y_RTOS+1, "[I]", SMLSIZE); lcd_outdezAtt(lcdLastPos, MENU_DEBUG_Y_RTOS, stackAvailable(), UNSIGN|LEFT); lcd_puts(3*FW, 7*FH+1, STR_MENUTORESET); lcd_status_line(); }