diff --git a/CHANGELOG.md b/CHANGELOG.md index d4d879b..2444ef9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ All notable changes to this project are documented here. Format loosely follows [Keep a Changelog](https://keepachangelog.com/). +## [Unreleased] + +### Changed +- The JVM backend's heap, previously fixed at `-Xmx14g`, is now configurable via the `AUTOPYARA_JVM_HEAP` environment variable (e.g. `AUTOPYARA_JVM_HEAP=4g`), still defaulting to `14g`. Lets `AutoPYara()` run on smaller machines. + ## [0.1.2] - 2026-09-03 ### Fixed diff --git a/autopyara/interface.py b/autopyara/interface.py index babda08..bbf4c4b 100644 --- a/autopyara/interface.py +++ b/autopyara/interface.py @@ -41,11 +41,13 @@ def _start_jvm(cls): print(f"[*] Initializing Backend: {jar_path}") + heap = os.getenv("AUTOPYARA_JVM_HEAP", "14g") + try: jpype.startJVM( jpype.getDefaultJVMPath(), f"-Djava.class.path={jar_path}", - "-Xmx14g", # Memory limit + f"-Xmx{heap}", # Memory limit (override with AUTOPYARA_JVM_HEAP, e.g. "4g") convertStrings=True ) cls._jvm_started = True diff --git a/docs/architecture.md b/docs/architecture.md index 0c224c3..23fdc1e 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -143,7 +143,10 @@ cluster.resetYaraState() # clear state before reuse The result dictionary carries `rule_string`, `k_clusters`, `strings`, `file_count`, `total_files`, `TP`, `TP_total`, `conditions_min`, `conditions_max`, `gram_size`, and `byte_candidate_count`. It is `None` when no rule satisfying the configured constraints could be built. -The JVM is started once per process, and its heap is currently fixed at 14 GB in [`interface.py`](https://github.com/Botacin-s-Lab/AutoPYaraPyPI/blob/main/autopyara/interface.py) — worth knowing if you are running on a memory-constrained machine. +The JVM is started once per process, with a heap that defaults to 14 GB; set the +`AUTOPYARA_JVM_HEAP` environment variable (e.g. `AUTOPYARA_JVM_HEAP=4g`) before +constructing `AutoPYara()` to lower it on a memory-constrained machine — see +[`interface.py`](https://github.com/Botacin-s-Lab/AutoPYaraPyPI/blob/main/autopyara/interface.py). ## How the jar gets into the Python package