From d3badd1fd73621d1d8b777902cf66cef626d16dc Mon Sep 17 00:00:00 2001 From: caheckman <48068198+caheckman@users.noreply.github.com> Date: Wed, 10 Jun 2020 18:20:30 -0400 Subject: [PATCH] Make FID cache size match the number of functions --- .../java/ghidra/feature/fid/service/FidProgramSeeker.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Ghidra/Features/FunctionID/src/main/java/ghidra/feature/fid/service/FidProgramSeeker.java b/Ghidra/Features/FunctionID/src/main/java/ghidra/feature/fid/service/FidProgramSeeker.java index c6157af54a..f417cdecf7 100644 --- a/Ghidra/Features/FunctionID/src/main/java/ghidra/feature/fid/service/FidProgramSeeker.java +++ b/Ghidra/Features/FunctionID/src/main/java/ghidra/feature/fid/service/FidProgramSeeker.java @@ -48,7 +48,7 @@ public class FidProgramSeeker { public final int MAX_NUM_PARENTS_FOR_SCORE = 500; // Limit number of (useless) parent (caller) functions - private final int CACHE_SIZE = 120000; // Maximum number of FidQuadHash cached + private final int MAX_CACHE_SIZE = 2000000; // Maximum number of FidQuadHash cached private final float scoreThreshold; // Code unit score a function must achieve to be considered a match private final int mediumHashCodeUnitLengthLimit; @@ -72,7 +72,10 @@ public class FidProgramSeeker { this.scoreThreshold = scoreThreshold; this.mediumHashCodeUnitLengthLimit = mediumHashCodeUnitLengthLimit; FidHasherFactory factory = new FidHasherFactory(hasher); - this.cacheFactory = new FIDFixedSizeMRUCachingFactory(factory, CACHE_SIZE); + int cacheSize = program.getFunctionManager().getFunctionCount(); + cacheSize = (cacheSize < 100) ? 100 : cacheSize; + cacheSize = (cacheSize > MAX_CACHE_SIZE) ? MAX_CACHE_SIZE : cacheSize; + this.cacheFactory = new FIDFixedSizeMRUCachingFactory(factory, cacheSize); } public static ArrayList getChildren(Function function, boolean followThunks) {