From 68e360b5c6270081c5a425cb439a8298dbe8eafe Mon Sep 17 00:00:00 2001 From: Greg DiCristofaro Date: Mon, 11 Sep 2023 15:42:10 -0400 Subject: [PATCH 1/4] show warning if insufficient memory --- .../org/sleuthkit/autopsy/core/Installer.java | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/Core/src/org/sleuthkit/autopsy/core/Installer.java b/Core/src/org/sleuthkit/autopsy/core/Installer.java index 24c40e9967..662759f800 100644 --- a/Core/src/org/sleuthkit/autopsy/core/Installer.java +++ b/Core/src/org/sleuthkit/autopsy/core/Installer.java @@ -20,8 +20,10 @@ package org.sleuthkit.autopsy.core; import com.sun.jna.platform.win32.Kernel32; import java.awt.Cursor; +import java.awt.GraphicsEnvironment; import java.io.File; import java.io.IOException; +import java.lang.management.ManagementFactory; import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; @@ -34,6 +36,7 @@ import java.util.logging.Level; import javafx.application.Platform; import javafx.embed.swing.JFXPanel; import javax.imageio.ImageIO; +import javax.swing.JOptionPane; import net.sf.sevenzipjbinding.SevenZip; import net.sf.sevenzipjbinding.SevenZipNativeInitializationException; import org.apache.commons.io.FileUtils; @@ -41,6 +44,7 @@ import org.apache.commons.lang3.StringUtils; import org.openide.modules.InstalledFileLocator; import org.openide.modules.ModuleInstall; import org.openide.util.NbBundle; +import org.openide.util.NbBundle.Messages; import org.openide.windows.WindowManager; import org.sleuthkit.autopsy.actions.IngestRunningCheck; import org.sleuthkit.autopsy.casemodule.Case; @@ -373,6 +377,7 @@ public class Installer extends ModuleInstall { @Override public void restored() { super.restored(); + checkMemoryAvailable(); ensurePythonModulesFolderExists(); ensureClassifierFolderExists(); ensureOcrLanguagePacksFolderExists(); @@ -392,6 +397,48 @@ public class Installer extends ModuleInstall { preloadTranslationServices(); } + /** + * Checks system resources logging any potential issues. + */ + @Messages({ + "Installer_checkMemoryAvailable_physicalRamExpected_title=System Does Not Meet Requirements", + "# {0} - physicalMemory", + "Installer_checkMemoryAvailable_physicalRamExpected_desc=Physical memory: {0}, is less than the 8GB required. Some aspects of the application may not work as expected.", + "Installer_checkMemoryAvailable_maxMemExpected_title=System Does Not Meet Requirements", + "# {0} - maxMemory", + "Installer_checkMemoryAvailable_maxMemExpected_desc=Maximum JVM memory: {0}, is less than the 2GB required. Some aspects of the application may not work as expected." + }) + private void checkMemoryAvailable() { + long memorySize = ((com.sun.management.OperatingSystemMXBean) ManagementFactory + .getOperatingSystemMXBean()).getTotalMemorySize(); + if (memorySize < 8_000_000) { + String desc = Bundle.Installer_checkMemoryAvailable_physicalRamExpected_desc(FileUtils.byteCountToDisplaySize(memorySize)); + + logger.log(Level.SEVERE, desc); + if (!GraphicsEnvironment.isHeadless() && RuntimeProperties.runningWithGUI()) { + JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(), + "" + desc + "", + Bundle.Installer_checkMemoryAvailable_physicalRamExpected_title(), + JOptionPane.WARNING_MESSAGE); + } + return; + } + + long maxMemory = Runtime.getRuntime().maxMemory(); + if (maxMemory < 2_000_000) { + String desc = Bundle.Installer_checkMemoryAvailable_maxMemExpected_desc(FileUtils.byteCountToDisplaySize(maxMemory)); + + logger.log(Level.SEVERE, desc); + if (!GraphicsEnvironment.isHeadless() && RuntimeProperties.runningWithGUI()) { + JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(), + "" + desc + "", + Bundle.Installer_checkMemoryAvailable_maxMemExpected_title(), + JOptionPane.WARNING_MESSAGE); + } + return; + } + } + /** * Initializes 7zip-java bindings. We are performing initialization once * because we encountered issues related to file locking when initialization From 6478dde7073de29fa5abad3e71295a7deb38008d Mon Sep 17 00:00:00 2001 From: Greg DiCristofaro Date: Mon, 11 Sep 2023 20:01:53 -0400 Subject: [PATCH 2/4] just logging --- .../org/sleuthkit/autopsy/core/Installer.java | 24 ++++--------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/core/Installer.java b/Core/src/org/sleuthkit/autopsy/core/Installer.java index 662759f800..935966adc6 100644 --- a/Core/src/org/sleuthkit/autopsy/core/Installer.java +++ b/Core/src/org/sleuthkit/autopsy/core/Installer.java @@ -401,10 +401,8 @@ public class Installer extends ModuleInstall { * Checks system resources logging any potential issues. */ @Messages({ - "Installer_checkMemoryAvailable_physicalRamExpected_title=System Does Not Meet Requirements", "# {0} - physicalMemory", "Installer_checkMemoryAvailable_physicalRamExpected_desc=Physical memory: {0}, is less than the 8GB required. Some aspects of the application may not work as expected.", - "Installer_checkMemoryAvailable_maxMemExpected_title=System Does Not Meet Requirements", "# {0} - maxMemory", "Installer_checkMemoryAvailable_maxMemExpected_desc=Maximum JVM memory: {0}, is less than the 2GB required. Some aspects of the application may not work as expected." }) @@ -412,30 +410,16 @@ public class Installer extends ModuleInstall { long memorySize = ((com.sun.management.OperatingSystemMXBean) ManagementFactory .getOperatingSystemMXBean()).getTotalMemorySize(); if (memorySize < 8_000_000) { - String desc = Bundle.Installer_checkMemoryAvailable_physicalRamExpected_desc(FileUtils.byteCountToDisplaySize(memorySize)); - + String desc = Bundle.Installer_checkMemoryAvailable_physicalRamExpected_desc( + FileUtils.byteCountToDisplaySize(memorySize)); logger.log(Level.SEVERE, desc); - if (!GraphicsEnvironment.isHeadless() && RuntimeProperties.runningWithGUI()) { - JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(), - "" + desc + "", - Bundle.Installer_checkMemoryAvailable_physicalRamExpected_title(), - JOptionPane.WARNING_MESSAGE); - } - return; } long maxMemory = Runtime.getRuntime().maxMemory(); if (maxMemory < 2_000_000) { - String desc = Bundle.Installer_checkMemoryAvailable_maxMemExpected_desc(FileUtils.byteCountToDisplaySize(maxMemory)); - + String desc = Bundle.Installer_checkMemoryAvailable_maxMemExpected_desc( + FileUtils.byteCountToDisplaySize(maxMemory)); logger.log(Level.SEVERE, desc); - if (!GraphicsEnvironment.isHeadless() && RuntimeProperties.runningWithGUI()) { - JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(), - "" + desc + "", - Bundle.Installer_checkMemoryAvailable_maxMemExpected_title(), - JOptionPane.WARNING_MESSAGE); - } - return; } } From 5ad95a9e7144306e18491f0831565dd6c657b8ca Mon Sep 17 00:00:00 2001 From: Greg DiCristofaro Date: Tue, 12 Sep 2023 08:51:41 -0400 Subject: [PATCH 3/4] add in catch --- .../org/sleuthkit/autopsy/core/Installer.java | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/core/Installer.java b/Core/src/org/sleuthkit/autopsy/core/Installer.java index 935966adc6..c3b44d324b 100644 --- a/Core/src/org/sleuthkit/autopsy/core/Installer.java +++ b/Core/src/org/sleuthkit/autopsy/core/Installer.java @@ -407,19 +407,27 @@ public class Installer extends ModuleInstall { "Installer_checkMemoryAvailable_maxMemExpected_desc=Maximum JVM memory: {0}, is less than the 2GB required. Some aspects of the application may not work as expected." }) private void checkMemoryAvailable() { - long memorySize = ((com.sun.management.OperatingSystemMXBean) ManagementFactory - .getOperatingSystemMXBean()).getTotalMemorySize(); - if (memorySize < 8_000_000) { - String desc = Bundle.Installer_checkMemoryAvailable_physicalRamExpected_desc( - FileUtils.byteCountToDisplaySize(memorySize)); - logger.log(Level.SEVERE, desc); + try { + long memorySize = ((com.sun.management.OperatingSystemMXBean) ManagementFactory + .getOperatingSystemMXBean()).getTotalMemorySize(); + if (memorySize < 8_000_000) { + String desc = Bundle.Installer_checkMemoryAvailable_physicalRamExpected_desc( + FileUtils.byteCountToDisplaySize(memorySize)); + logger.log(Level.SEVERE, desc); + } + } catch (Throwable t) { + logger.log(Level.SEVERE, "There was an error fetching physical memory size", t); } - long maxMemory = Runtime.getRuntime().maxMemory(); - if (maxMemory < 2_000_000) { - String desc = Bundle.Installer_checkMemoryAvailable_maxMemExpected_desc( - FileUtils.byteCountToDisplaySize(maxMemory)); - logger.log(Level.SEVERE, desc); + try { + long maxMemory = Runtime.getRuntime().maxMemory(); + if (maxMemory < 2_000_000) { + String desc = Bundle.Installer_checkMemoryAvailable_maxMemExpected_desc( + FileUtils.byteCountToDisplaySize(maxMemory)); + logger.log(Level.SEVERE, desc); + } + } catch (Throwable t) { + logger.log(Level.SEVERE, "There was an error fetching jvm max memory", t); } } From cc2d687b418a405b08f6092ef5adbdb384fcabf6 Mon Sep 17 00:00:00 2001 From: Greg DiCristofaro Date: Tue, 12 Sep 2023 09:52:00 -0400 Subject: [PATCH 4/4] fix --- .../org/sleuthkit/autopsy/core/Bundle.properties-MERGED | 4 ++++ Core/src/org/sleuthkit/autopsy/core/Installer.java | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/core/Bundle.properties-MERGED b/Core/src/org/sleuthkit/autopsy/core/Bundle.properties-MERGED index c0407c965b..fce17d6606 100755 --- a/Core/src/org/sleuthkit/autopsy/core/Bundle.properties-MERGED +++ b/Core/src/org/sleuthkit/autopsy/core/Bundle.properties-MERGED @@ -2,6 +2,10 @@ Installer.closing.confirmationDialog.message=Ingest is running, are you sure you Installer.closing.confirmationDialog.title=Ingest is Running # {0} - exception message Installer.closing.messageBox.caseCloseExceptionMessage=Error closing case: {0} +# {0} - maxMemory +Installer_checkMemoryAvailable_maxMemExpected_desc=Maximum JVM memory: {0}, is less than the 2 GB required. Some aspects of the application may not work as expected. +# {0} - physicalMemory +Installer_checkMemoryAvailable_physicalRamExpected_desc=Physical memory: {0}, is less than the 8 GB required. Some aspects of the application may not work as expected. OpenIDE-Module-Display-Category=Infrastructure OpenIDE-Module-Long-Description=\ This is the core Autopsy module.\n\n\ diff --git a/Core/src/org/sleuthkit/autopsy/core/Installer.java b/Core/src/org/sleuthkit/autopsy/core/Installer.java index c3b44d324b..0cbafe987e 100644 --- a/Core/src/org/sleuthkit/autopsy/core/Installer.java +++ b/Core/src/org/sleuthkit/autopsy/core/Installer.java @@ -402,15 +402,15 @@ public class Installer extends ModuleInstall { */ @Messages({ "# {0} - physicalMemory", - "Installer_checkMemoryAvailable_physicalRamExpected_desc=Physical memory: {0}, is less than the 8GB required. Some aspects of the application may not work as expected.", + "Installer_checkMemoryAvailable_physicalRamExpected_desc=Physical memory: {0}, is less than the 8 GB required. Some aspects of the application may not work as expected.", "# {0} - maxMemory", - "Installer_checkMemoryAvailable_maxMemExpected_desc=Maximum JVM memory: {0}, is less than the 2GB required. Some aspects of the application may not work as expected." + "Installer_checkMemoryAvailable_maxMemExpected_desc=Maximum JVM memory: {0}, is less than the 2 GB required. Some aspects of the application may not work as expected." }) private void checkMemoryAvailable() { try { long memorySize = ((com.sun.management.OperatingSystemMXBean) ManagementFactory .getOperatingSystemMXBean()).getTotalMemorySize(); - if (memorySize < 8_000_000) { + if (memorySize < 8_000_000_000L) { String desc = Bundle.Installer_checkMemoryAvailable_physicalRamExpected_desc( FileUtils.byteCountToDisplaySize(memorySize)); logger.log(Level.SEVERE, desc); @@ -421,7 +421,7 @@ public class Installer extends ModuleInstall { try { long maxMemory = Runtime.getRuntime().maxMemory(); - if (maxMemory < 2_000_000) { + if (maxMemory < 2_000_000_000L) { String desc = Bundle.Installer_checkMemoryAvailable_maxMemExpected_desc( FileUtils.byteCountToDisplaySize(maxMemory)); logger.log(Level.SEVERE, desc);