/** * Updates the memory information of the memory monitor.<p> */ protected void updateStatus() { m_memoryCurrent.update(); m_memoryAverage.calculateAverage(m_memoryCurrent); } }
/** * Calculates the average memory consumption by updating the stored information with * the provided current information.<p> * * @param currentStatus the memory status to update the average with */ public void calculateAverage(CmsMemoryStatus currentStatus) { int newCount = m_count + 1; m_maxMemory = ((m_count * m_maxMemory) + currentStatus.getMaxMemory()) / newCount; m_totalMemory = ((m_count * m_totalMemory) + currentStatus.getTotalMemory()) / newCount; m_usedMemory = ((m_count * m_usedMemory) + currentStatus.getUsedMemory()) / newCount; m_freeMemory = ((m_count * m_freeMemory) + currentStatus.getFreeMemory()) / newCount; m_usage = (m_usedMemory * 100) / m_maxMemory; m_count = newCount; }
/** * Returns true if the system runs low on memory.<p> * * @return true if the system runs low on memory */ public boolean lowMemory() { return ((m_maxUsagePercent > 0) && (m_memoryCurrent.getUsage() > m_maxUsagePercent)); }
/** * Initializes a new instance of the memory status with the current memory values.<p> */ public CmsMemoryStatus() { update(); }
m_memoryAverage = new CmsMemoryStatus(); m_memoryCurrent = new CmsMemoryStatus();
+ "\n\n" + "Memory maximum heap size: " + m_memoryCurrent.getMaxMemory() + " mb\n" + "Memory current heap size: "
/** * Initializes a new instance of the memory status with the current memory values.<p> */ public CmsMemoryStatus() { update(); }
m_memoryAverage = new CmsMemoryStatus(); m_memoryCurrent = new CmsMemoryStatus();
/** * Calculates the average memory consumption by updating the stored information with * the provided current information.<p> * * @param currentStatus the memory status to update the average with */ public void calculateAverage(CmsMemoryStatus currentStatus) { int newCount = m_count + 1; m_maxMemory = ((m_count * m_maxMemory) + currentStatus.getMaxMemory()) / newCount; m_totalMemory = ((m_count * m_totalMemory) + currentStatus.getTotalMemory()) / newCount; m_usedMemory = ((m_count * m_usedMemory) + currentStatus.getUsedMemory()) / newCount; m_freeMemory = ((m_count * m_freeMemory) + currentStatus.getFreeMemory()) / newCount; m_usage = m_usedMemory * 100 / m_maxMemory; m_count = newCount; }
/** * Updates the memory information of the memory monitor.<p> */ protected void updateStatus() { m_memoryCurrent.update(); m_memoryAverage.calculateAverage(m_memoryCurrent); } }
/** * Returns the current memory status.<p> * * @return the memory status */ public CmsMemoryStatus getMemoryStatus() { m_memoryCurrent.update(); return m_memoryCurrent; }
/** * Returns true if the system runs low on memory.<p> * * @return true if the system runs low on memory */ public boolean lowMemory() { return ((m_maxUsagePercent > 0) && (m_memoryCurrent.getUsage() > m_maxUsagePercent)); }
LOG.warn(Messages.get().getBundle().key( Messages.LOG_MM_WARNING_MEM_CONSUME_2, new Long(m_memoryCurrent.getUsage()), new Integer(m_maxUsagePercent))); } else { Messages.LOG_MM_WARNING_MEM_STATUS_6, new Object[] { new Long(m_memoryCurrent.getMaxMemory()), new Long(m_memoryCurrent.getTotalMemory()), new Long(m_memoryCurrent.getFreeMemory()), new Long(m_memoryCurrent.getUsedMemory()), new Long(m_memoryCurrent.getUsage()), new Integer(m_maxUsagePercent)})); } else { Messages.LOG_MM_WARNING_MEM_STATUS_6, new Object[] { new Long(m_memoryCurrent.getMaxMemory()), new Long(m_memoryCurrent.getTotalMemory()), new Long(m_memoryCurrent.getFreeMemory()), new Long(m_memoryCurrent.getUsedMemory()), new Long(m_memoryCurrent.getUsage()), new Integer(m_maxUsagePercent), new Long(totalSize), Messages.LOG_MM_WARNING_MEM_STATUS_AVG_6, new Object[] { new Long(m_memoryAverage.getMaxMemory()),
Messages.get().getBundle().key( Messages.LOG_MM_WARNING_MEM_CONSUME_2, new Long(m_memoryCurrent.getUsage()), new Integer(m_maxUsagePercent))); } else { Messages.LOG_MM_WARNING_MEM_STATUS_6, new Object[] { new Long(m_memoryCurrent.getMaxMemory()), new Long(m_memoryCurrent.getTotalMemory()), new Long(m_memoryCurrent.getFreeMemory()), new Long(m_memoryCurrent.getUsedMemory()), new Long(m_memoryCurrent.getUsage()), new Integer(m_maxUsagePercent)})); } else { Messages.LOG_MM_WARNING_MEM_STATUS_6, new Object[] { new Long(m_memoryCurrent.getMaxMemory()), new Long(m_memoryCurrent.getTotalMemory()), new Long(m_memoryCurrent.getFreeMemory()), new Long(m_memoryCurrent.getUsedMemory()), new Long(m_memoryCurrent.getUsage()), new Integer(m_maxUsagePercent), new Long(totalSize), Messages.LOG_MM_WARNING_MEM_STATUS_AVG_6, new Object[] { new Long(m_memoryAverage.getMaxMemory()),
+ "\n\n" + "Memory maximum heap size: " + m_memoryCurrent.getMaxMemory() + " mb\n" + "Memory current heap size: " + m_memoryCurrent.getTotalMemory() + " mb\n\n" + "Memory currently used : " + m_memoryCurrent.getUsedMemory() + " mb (" + m_memoryCurrent.getUsage() + "%)\n" + "Memory currently unused : " + m_memoryCurrent.getFreeMemory() + " mb\n\n\n";