From a72b5194409c8d39e6f858d2372576d79fd5d036 Mon Sep 17 00:00:00 2001 From: Michael Peter Christen Date: Sat, 4 Jul 2026 14:08:46 +0200 Subject: fix for memory setting --- htroot/env/markdown.css | 64 +++++++++++++++++++++++++ source/net/yacy/htroot/PerformanceQueues_p.java | 31 +++++++++++- 2 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 htroot/env/markdown.css diff --git a/htroot/env/markdown.css b/htroot/env/markdown.css new file mode 100644 index 000000000..9478e90c6 --- /dev/null +++ b/htroot/env/markdown.css @@ -0,0 +1,64 @@ +/* + * Shared styles for rendered markdown content, scoped to the .markdown-body class. + * Used by yacychat.html (chat messages) and LogReports_p.html (log reports); + * rendered together with js/yacy-markdown.js. + * Page-specific container properties (padding, max-height, borders) stay local + * to the page stylesheets. + */ + +.markdown-body { + white-space: normal; +} + +.markdown-body, +.markdown-body * { + font-family: 'Roboto Mono', 'Menlo', 'Consolas', monospace !important; /* Force markdown output and descendants to stay monospace, FTW! */ +} + +.markdown-body h1, +.markdown-body h2, +.markdown-body h3, +.markdown-body h4, +.markdown-body h5, +.markdown-body h6, +.markdown-body p, +.markdown-body li, +.markdown-body pre, +.markdown-body code { + font-size: 1.2rem; + line-height: 1.6; +} + +.markdown-body table { + border-collapse: collapse; + border: 1px solid #c3cbd9; + margin: 8px 0; +} + +.markdown-body th, +.markdown-body td { + border: 1px solid #c3cbd9; + padding: 4px 8px; +} + +.markdown-body th { + background-color: rgba(27,31,35,0.05); +} + +.markdown-body pre { + background-color: #2c3e50; + border: 1px solid #dfe2e5; + border-radius: 4px; + padding: 2px; + overflow-x: auto; + font-family: 'Roboto Mono', 'Menlo', 'Consolas', monospace; + white-space: pre; +} + +.markdown-body code { + font-family: 'Roboto Mono', 'Menlo', 'Consolas', monospace; + font-size: 0.95rem; + background-color: rgba(27,31,35,0.05); + padding: 2px 4px; + border-radius: 4px; +} diff --git a/source/net/yacy/htroot/PerformanceQueues_p.java b/source/net/yacy/htroot/PerformanceQueues_p.java index b6280fc81..5818d572a 100644 --- a/source/net/yacy/htroot/PerformanceQueues_p.java +++ b/source/net/yacy/htroot/PerformanceQueues_p.java @@ -397,8 +397,7 @@ public class PerformanceQueues_p { SwitchboardConstants.REMOTESEARCH_MAXLOAD_SOLR_DEFAULT)); // parse initialization memory settings - final String Xmx = sb.getConfig("javastart_Xmx", "Xmx600m").substring(3); - prop.put("Xmx", Xmx.substring(0, Xmx.length() - 1)); + prop.put("Xmx", xmxToMebibytes(sb.getConfig("javastart_Xmx", "Xmx600m"))); final long diskFree = sb.getConfigLong(SwitchboardConstants.RESOURCE_DISK_FREE_MIN_STEADYSTATE, 3000L); final long diskFreeHardlimit = sb.getConfigLong(SwitchboardConstants.RESOURCE_DISK_FREE_MIN_UNDERSHOT, 1000L); @@ -421,6 +420,34 @@ public class PerformanceQueues_p { return prop; } + /** + * Parse a JVM maximum heap size option like "Xmx600m", "Xmx16g" or "Xmx2048k" + * into mebibytes for display and editing on the Performance page. The value may + * have been edited manually in the config file, so all JVM unit suffixes + * (k/m/g/t, case-insensitive) and a plain byte count without suffix must be + * understood; simply cutting off the last character would misread "Xmx16g" as + * 16 MiB and a subsequent form submit would rewrite it as "Xmx16m". + * @return the heap size in mebibytes, or 600 if the value cannot be parsed + */ + private static long xmxToMebibytes(String xmx) { + try { + if (xmx.startsWith("Xmx")) xmx = xmx.substring(3); + xmx = xmx.trim(); + final char unit = Character.toLowerCase(xmx.charAt(xmx.length() - 1)); + if (Character.isDigit(unit)) return Long.parseLong(xmx) / (1024L * 1024L); // no suffix means bytes + final long value = Long.parseLong(xmx.substring(0, xmx.length() - 1)); + switch (unit) { + case 'k': return value / 1024L; + case 'm': return value; + case 'g': return value * 1024L; + case 't': return value * 1024L * 1024L; + default: return 600L; + } + } catch (final RuntimeException e) { + return 600L; + } + } + private static String d(final String a, final String b) { return (a == null) ? b : a; } -- cgit v1.2.3