waytrade / ib-gateway-docker

Docker image with IB Gateway and IBC
MIT License
57 stars 33 forks source link

Adjust memory #6

Closed electic closed 2 years ago

electic commented 2 years ago

Thank you for putting this together. One question is how do you change the Java VM options? Right now it has it set to 768MB but what if we want to change that?

Generating the JAVA VM options
Java VM Options=-Xmx768m -XX:+UseG1GC -XX:MaxGCPauseMillis=200 -XX:ParallelGCThreads=20 -XX:ConcGCThreads=5 -XX:InitiatingHeapOccupancyPercent=70 -Dtwslaunch.autoupdate.serviceImpl=com.ib.tws.twslaunch.install4j.Install4jAutoUpdateService -Dchannel=latest -Dexe4j.isInstall4j=true -Dinstall4jType=standalone
mfrener commented 2 years ago

Java VM is configured on the ibgateway.vmoptions file. The current dockerfile does not allow to customize this (only jts.config and ibc config), but you can easily add. How to:

maximum Java heap size

-Xmx768m

GC settings

-XX:+UseG1GC -XX:MaxGCPauseMillis=200 -XX:ParallelGCThreads=20 -XX:ConcGCThreads=5 -XX:InitiatingHeapOccupancyPercent=70

-Dinstaller.uuid=dc71edfa-a1bb-4c1e-a0d9-9bac192054cd -DvmOptionsPath=/root/Jts/ibgateway/1012.2c/ibgateway.vmoptions -Dsun.awt.nopixfmt=true -Dsun.java2d.noddraw=true -Dswing.boldMetal=false -Dsun.locale.formatasdefault=true



- Save the file to ./config/ibgateway/ibgateway.vmoptions and set -Xmx768m to what you need
- Open ./Dockerfile (https://github.com/waytrade/ib-gateway-docker/blob/master/Dockerfile) and search for "COPY ./config/ibgateway/jts.ini /root/Jts/jts.ini" (line 33). That is where jts.ini file coped. After that line, add:
```COPY ./config/ibgateway/ibgateway.vmoptions /root/Jts/ibgateway/${IB_GATEWAY_VERSION}/ibgateway.vmoptions``` to also copy your ibgateway.vmoptions
- Re-build the image
IB Gateway will now use the ibgateway.vmoptions overwritten by the COPY, instead of the original installed by ./ibgateway-${IB_GATEWAY_VERSION}-standalone-linux-x64.sh
electic commented 2 years ago

Great minds think alike. I went through the code to figure this out as well. I am happy to do a pull request if it helps. Let me know.

mfrener commented 2 years ago

PRs always welcome ;)

mfrener commented 2 years ago

PR merged to master