shannah / jdeploy

Developer friendly desktop deployment tool
https://www.jdeploy.com
Apache License 2.0
354 stars 19 forks source link

JVM args not picking #133

Closed theapache64 closed 2 months ago

theapache64 commented 3 months ago

Here's my package.json

{
  "bin": {"dex-diff": "jdeploy-bundle/jdeploy.js"},
  "author": "theapache64",
  "description": "A tool to compare two APK files at dex level",
  "main": "index.js",
  "preferGlobal": "true",
  "repository": "https://github.com/theapache64/dex-diff",
  "version": "0.0.7",
  "jdeploy": {
    "jdk": "false",
    "javaVersion": "17",
    "jar": "dex-diff.main.jar",
    "javafx": "false",
    "title": "dex-diff",
    "args": [
      "-Xms8G",
      "-Xmx12G"
    ]
  },
  "dependencies": {
    "command-exists-promise": "^2.0.2",
    "node-fetch": "2.6.7",
    "tar": "^4.4.8",
    "yauzl": "^2.10.0",
    "shelljs": "^0.8.4"
  },
  "license": "ISC",
  "name": "dex-diff",
  "files": ["jdeploy-bundle"],
  "scripts": {"test": "echo \"Error: no test specified\" && exit 1"}
}

but when I query the maxMemory, I get this

fun main(args: Array<String>) {
    println("QuickTag: :main: ${args.toList()}")
    // print heap size in MB
    val heapSize = Runtime.getRuntime().maxMemory() / 1024 / 1024
    println("🧠 Heap size: $heapSize MB")
    exitProcess(0)
}

image

shannah commented 3 months ago

What happens if you set it to less than 4G? like -Xmx2G.

Does the output change or is it always 4096?

theapache64 commented 3 months ago

Yes. Its always 4096

shannah commented 2 months ago

I cannot reproduce.

Tried a sample app, you can see here. https://github.com/shannah/test-set-memory/releases

I add a tooltip to show min and max memory.

https://github.com/shannah/test-set-memory/blob/master/src/main/java/com/github/shannah/testsetmemory/TestSetMemory.java#L27-L30

startButton.setToolTipText(
                "Free memory: " + Runtime.getRuntime().freeMemory() + "; "
                        + "Total memory: " + Runtime.getRuntime().totalMemory() + "; "
                        + "Max memory: " + Runtime.getRuntime().maxMemory());

The package.json: https://github.com/shannah/test-set-memory/blob/master/package.json

With args:

 "args": [
            "-Xms8G",
            "-Xmx8G"
        ],

When I changed this to 4G, it comes up with ~4G memory in the tooltip. Bump it to 8G, and the tooltip adjusts accordingly.

Tested in Mac and Windows.

theapache64 commented 4 weeks ago

@shannah I've the same config : https://github.com/theapache64/dex-diff/blob/31a19516b4ef4f89435ab15469ead37813f02774/package.json#L16 and it still doesn't work for me. Did you get chance to test it a CLI/terminal app ?

theapache64 commented 4 weeks ago

@shannah I did a small log debugging and it looks like the args are not getting attached in here : image

what might be the reason ? 🤔

theapache64 commented 4 weeks ago

and it works when i manually inject the args like this

image