How to configure Java Virtual Machine memory Parameters in TWS

Overview: 

General notes on the Java virtual machine and memory parameters

Trader Workstation is a Java-based application. Programs which are compiled using Java execute within a Java virtual machine (JVM) process which manages the interactions between the program, and the operating system and hardware. The Java virtual machine dynamically manages the memory usage for the program running in it. There are many technical aspects to how the memory is managed, but there are two primary spaces or blocks of memory which are of concern for running the TWS: the heap space, and the permanent generation (permgen) space.

The heap is the area in memory where all class instances and arrays are allocated. The heap is created when the JVM is started, and space is periodically reclaimed by the garbage collector (GC), the Java Virtual Machine's automatic storage management system. There is also non-heap space, known as the permanent generation space, utilized by the Java Virtual Machine to hold code which typically has a longer life in memory, or a specific usage. If either of these spaces are not sized correctly, errors can occur when the process runs out of memory in these spaces. If this occurs, the program will appear to be frozen or may crash completely, and the log files in the program directory for TWS (in C:\Jts, by default on Windows OS) will likely include one of the following errors:

  • java.lang.OutOfMemoryError: Java heap space
  • java.lang.OutOfMemoryError: PermGen space

When launching a Java program, it is possible to pass certain parameters to the Java virtual machine to adjust how much memory the process will use to run the program. The Xmx flag controls the maximum amount of memory to be used for the heap space, and the XX:MaxPermSize flag controls the maximum amount of memory to be used for the permanent generation space.

As we have released newer versions of TWS which contain more features, the memory required for the Java virtual machine to effectively run TWS has increased.

  • For users running TWS with a 32 bit version of Java, the MINIMUM memory for the heap size is 256 MB, and for the permanent generation space is 128 MB.
  • For users running TWS with a 64 bit version of Java, the MINIMUM memory for the heap size is 384 MB, and for the permanent generation space is 192 MB.


The above are the bare minimums necessary to run the program for most customers. Usage of many of the features in TWS will require higher memory allotments.

Some users may have old shortcuts or use custom scripts to launch TWS. It is crucial that these are updated accordingly to use at least the minimum memory parameters mentioned above. Some users who have extensive portfolios or execute large amount of orders may need to adjust the parameters to improve performance. The heap size can be increased if there is an OutOfMemoryError pertaining to the heap space.  Note, in our experience the memory should typically not need to be increased above 1024M in the heap and 256M in the permgen.

If at any time following adjusting the memory parameters, you receive an error that the system could not create the Java Virtual Machine, this indicates the memory increase was too aggressive, and you need to scale back the parameters.
 

**Please note the following:  Starting with Java 8, the XX:MaxPermSize parameter has been deprecated. When running TWS with Java 8, the XX:MaxPermSize parameter will be ignored at runtime if present; this parameter could be simply omitted from the start-up script.

Browser-based TWS (Java WebStart version)
IB uses a script on our website to dynamically serve a JNLP file with different memory parameters based on the URL request from the browser. When launching TWS from our website, you can add the Xmx and Xmps parameters to the URL to configure the heap size and and permanent generation space size, respectively for the Java virtual machine process which will run TWS. For example:

http://www.interactivebrokers.com/java/classes/latest.Xmx-768M.Xmps-128M...

will result in a JNLP file with the max heap size set to 768 mb and the max permanent generation space size set to 128MB.

If you encountered a resource allocation message when launching a previously saved copy of the JNLP file, and were directed to this webpage, please download a new version of the JNLP file from here.  The file you are using is likely out-of-date, and does not contain the correct resource allocation parameters for your operating system.

Standalone TWS on Windows
To adjust the memory parameters used when launching TWS from the desktop or start menu shortcut:

  •   Right-click the shortcut and select Properties
  •   On the shortcut dialog window, find the Xmx and XX:MaxPermSize flags in the target field
  •   Adjust the values following the flags to the desired size

Standalone TWS on Mac
To adjust the memory parameters used when launching TWS using the Trader_Workstation_X.app icon:

  •     Hold Control and click (or right-click if you have a two-button mouse) on the application icon
  •     Choose "Show package contents" from the menu
  •     Open Contents > MacOS
  •     Open the JavaAppLauncher shell script file
  •     Find the Xmx and XX:MaxPermSize flags, and adjust the values following the flags to the desired size

Standalone TWS on UNIX (or Mac) via terminal command
When executing the command to start TWS from the terminal, adjust the values following the Xmx and XX:MaxPermSize flags to the desired size. For example, if you would normally launch using:

java -cp jts.jar:total.2013.jar -Xmx512M -XX:MaxPermSize=128M jclient.LoginFrame

but need to increase due to errors or freezing due to running out of memory, you can instead run:

java -cp jts.jar:total.2013.jar -Xmx768M -XX:MaxPermSize=256M jclient.LoginFrame

How to install Java on a Windows computer

General Information

When installing or updating the Java platform on your computer, it's recommended that that you maintain a single version (i.e, the latest) as multiple versions may adversely impact the operation of the TWS.  In this article we will first describe how to uninstall those Java platforms which might already reside on your computer and then how to install the latest Java Runtime Environment.


Section A - Remove all previous Java versions that might be installed on your PC:

  1. Click on the Start menu.
  2. Click on Control Panel.

 

  1. Set the "View By" selector to "Category".
  2. Click on "Uninstall a program". On Windows XP this feature is called "Add or remove programs".

 

  1. Find the first Java entry in the Installed Programs list
  2. Click on "Uninstall".  On Windows XP you need first to select the Java item from the list and then click on the button "Remove" which will appear on the right side of the selection box. If no Java items are listed, please skip steps from 6 to 11 and proceed directly to section B).

 

  1. You may now receive a message asking you to confirm your intention to uninstall the software. Confirm by clicking on OK.

 

  1. You may now receive a User Account Control warning message. In case your user has the required privileges, just confirm by clicking 'Yes' (8b). If you are logged in Windows with an user which does not have the privileges to install software, you will see in the same window, but as well the fields (8a) in which to enter the credentials of another user which has those privileges (usually 'Administrator'). Please enter the required credentials and then confirm with 'Yes' (8b)

 

  1. The uninstall process will start. Java will be uninstalled and the related entry eventually removed from the Installed Programs list.
  2. Uninstall all the other Java platforms which may be present on the Installed Programs list. Uninstall them one after each other, repeating the steps from 5 to 9 up to the point when you will not see any more Java item listed among the Installed Programs.
  3. Restart your computer. This Step MUST be performed in order to clean up completely the system from the old Java files and registry entries which might have been in use during the uninstall process.

 


Section B - Install the newest version of the Java Runtime Environment:

In this tutorial we describe the installation using Internet Explorer which is the browser installed by default on every Windows computer. If you prefer to use another browser (such as: Mozilla Firefox, Opera, Google Chrome, Safari) please take into account that the disposition and/or the content of the messages appearing during the first 10 steps might slightly differ.

 

  1. Open the Internet Explorer Browser and type "http://www.oracle.com/technetwork/java/javase/downloads/index.html" in the address bar. Then press the "Enter" key on your keyboard. The page will load.

 

  1. In the first section on this page - "Java Platform, Standard Edition", locate the blue "Download" button under the title "JRE". At the time the screenshots below have been done, latest release is 7u45. You might currently find other version number on this page. This does not represent an issue, since the page should provide only the latest release available, the one we need to install.

 

  1. Click on the radio button next to "Accept the License Agreement "
  2. Download the file correspondent to "Windows x86 Offline" which is the installer for the  32-bit JRE.

 

  1. Choose "Run". The download will start.

 

  1. Once finished you may receive a User Account Control warning message. In case your user has the required privileges, just confirm by clicking 'Yes' (6b). If you are logged in Windows with an user which does not have the privileges to install software, you will see in the same window, but as well the field (6a) where you should enter the credentials of another user which has those privileges (usually 'Administrator'). Please enter the required information and then confirm with 'Yes' (6b)

During this phase you might receive as well additional warning message/s from your Antivirus or Internet Security System asking you to confirm your intention to open/execute the file or to confirm that it is safe to open the file. After having checked that the file which is supposed to be executed is indeed the one you downloaded from the Oracle Web Site, answer positively.

 

  1. Proceed with the 32-bit JRE Java installation, using the default parameters, by clicking on the button "Install". 
     

 

  1. Complete the installation by clicking on the "Close" button

In case you have a 32-bit system, please skip steps from 9 to 13 and proceed directly to step 14. ONLY in case you use a 64-bit system, perform all the steps below:

 

  1. Download the .exe file correspondent to "Windows x64" which is the installer for the 64-bit JRE.

 

  1. Choose "Run". The download will start.

 

  1. You may receive a User Account Control warning message. In case your user has the required privileges, just confirm by clicking 'Yes' (11b). If you are logged on Windows with an user which does not have the privileges to install software, you will see in the same window, but as well the field (11a) where you should enter the credentials of another user which has those privileges (usually 'Administrator'). Please enter the required credentials and then confirm with 'Yes' (11b)
     

 

During this phase you might receive as well additional warning message/s from your Antivirus or Internet Security System asking you to confirm your intention to open/execute the file or to confirm that it is safe to open the file. After having checked that the file which is supposed to be executed is indeed the one you downloaded from the Oracle Web Site. Confirm by clicking on Yes.

 

  1. Proceed with the 64-bit JRE installation, using the default parameters.

 

  1. Complete the installation by clicking on the button "Close".

 

  1. Restart your computer. This Step MUST be performed in order to properly set up all the new Java components.

 

 

Other related Knowledge Base content

Title Video Article
How to clear Java cache on a Windows 7 computer KB2151 KB2149
How to clear Java cache on a Windows 8 computer KB2153 KB2146
How to clear Java cache on Windows XP N/A KB2148
How to clear Java cache on a Mac computer KB2152 N/A
How to clear Java cache on MAC OS X 10.7.3 and above N/A KB2147
How to clear Oracle Java cache on Linux/Unix N/A KB2145

 

 

如何在Windows系统上安装交易平台(TWS)

 

要求

盈透证券的交易平台基于Java程序,如果要在32位的Windows操作系统中安装并运行独立版本的交易平台,您需要安装32位的Java运行环境(JRE)。如果您的操作系统是64位的版本,那么您需要同时安装64位和32位的JRE。

有关设置Java平台的指示,请查看此页面:http://ibkb.interactivebrokers.com/zh-hans/article/2129

 

交易平台安装

本向导将描述交易平台独立版本的安装程序,默认用户电脑安装的浏览器为IE(Internet Explorer)。如果您希望使用其他浏览器(如Mozilla Firefox,Opera,Google Chrome或Safari),那么请注意,以下步骤中前六步中的内容可能会与您的实际情况有所出入。

请按照以下步骤下载并安装独立版本的交易平台:

  1. 打开IE并在地址栏中输入以下网址:https://www.ibkr.com.cn 或者https://www.interactivebrokers.com.hk
  2. 将鼠标光标指向“交易技术”菜单。
  3. 在弹出的菜单选项中选择“独立交易平台”。

 

  1.  点击页面下方的“安装交易平台”按钮。

 

  1. 如果您想下载最新版本的交易平台,请点击“下载交易平台(TWS)最新版本”(5a)。如果盈透客服指示您或您有特别的原因需要下载之前的版本,那么请点击“下载交易平台(TWS)”(5b)。

  1. 此时IE界面的底部会弹出一个对话框。请点击“运行”继续安装进程。

 

  1. 完成下载后,您可能会收到用户账户控制警告信息。如果您的用户名具有安装权限,那么只需点击“是”(7b)。如果用于登录Windows的用户名不具备安装软件的权限,那么您需要在登录框中 (7a) 输入具有安装权限(通常“管理员”具备这些权限)的用户名和密码,然后点击“是”(7b) 。

  

在此过程中,您可能收到杀毒软件或网络安全系统的警告信息,要求您确认是否要打开/执行文件或确认打开文件是否属于安全。在确认要执行的文件确实是从盈透网站中下载的文件后,请点击“确认”。  
 

 

  1. 随后交易平台安装程序将启动。请点击“继续”进行下一步操作。

 

  1. 现在您可以选择安装的程序。默认选项为“交易平台和IB网关”。请点击“继续”进行下一步操作。

 

  1.  默认的安装文件夹是“C:/Jts”。想要简化安装进程和考虑到符合Java平台访问相关文件系统的限制,我们建议您不要修改默认的路径,只需点击“继续”进下一步操作即可。

 

  1. 点击“继续”确认您准备开始安装交易平台。

 

  1. 安装完成后,点击“完成”退出安装程序。

 

  1. 交易平台图标会出现在桌面上。双击该图标登录交易平台。

     

 

How to install the Offline version of Trader Workstation (TWS) on a Windows PC

IMPORTANT NOTE: if you were previously storing your TWS settings to the cloud (by keeping the checkbox Use/Store Settings on Server on the TWS login screen activated), you can now recover those settings after TWS has been installed. If this is the case, it is important that, immediately after the TWS installation, before you login the first time, you remember to activate again the checkbox Use/Store Settings on Server on the login screen of the TWS. You can find more details here.

In this tutorial we describe the TWS installation using the Internet Explorer browser,  which is installed by default on every Windows PC. If you prefer to use another browser (such as: Mozilla Firefox or Google Chrome) please take into account that the disposition and/or the content of the messages appearing during the first three steps might slightly differ.

How to install Offline TWS Latest:

  1. Open the page www.ibkr.com in your browser, then click on the menu Technology --> TWS Software

  1. Scroll down the page, until you find the button for OFFLINE TWS LATEST. Click on it.
    Offline TWS Latest Installation 
     
  2. Below Offline TWS Latest for Windows, click the button DOWNLOAD

  3. At the bottom of your browser, a pop-up Security Warning bar will appear, click Run.Security Warning Bar - click RUN
  1. The Installation Wizard will now initialize, click Next>
    Installation Wizard - Next
  1. After the Installation completes, click Finish
    Installation Wizard - click Finish
     
  2. A TWS icon will now appear on your desktop. Double-click it to launch the Login box. Please notice that the icon will inlclude the actual build number (Build #) of the TWS you installed. Therefore you could see Trader Workstation 960 or Trader Workstation 961 etc.
    Trader Workstation Icon - Double-click to launch.

 

Recovering your Settings

  1.  Launch the TWS. Once the login screen has loaded, tick the checkbox Use/Store Settings on ServerCheck the box "Use/Store Settings on server"
     
  2. Enter your username and password and click Login. The TWS will now attempt to download your settings stored on the cloud and load them into the TWS
    Enter Username and Password then proceed to login
     

 

Mac OS X TWS Manual Installation Instructions

Overview: 

This type of installation will require you to launch the Trader Workstation through a Terminal window by using the string shown below in step 7. If you are not familiar with the use of Terminal, please use the automated installation package found here

Manual Jar File Installation

1. To install to the latest TWS Mac OS production release on your computer, hold down the Control Key, and with your mouse click on the button below:

2. From the menu, click "Download Link to Disk."
3. Once the file has downloaded to your desktop, move the file to your Home directory (this is a folder listed on your hard drive within the Users folder).
4. Access the command line terminal from the Applications menu. First select Utilities and then select Terminal.
5. At the command line, create a directory called IBJts and load TWS files by typing:

jar xf unixmacosx.jar

Press Return.

6. Change the directory to IBJts by typing:

cd IBJts

Press Return.

7. To run TWS, type or paste in the Terminal window the following: (** Please note that there is a space then ".", after LoginFrame **)

java -cp jts.jar:total.2013.jar -Xmx512M -XX:MaxPermSize=128M jclient.LoginFrame .

 Press Return.

How to install the Offline version of Trader Workstation (TWS) on a Mac OS

IMPORTANT NOTE: if you were previously storing your TWS settings to the cloud (by keeping the checkbox Use/Store Settings on Server on the TWS login screen activated), you can now recover those settings after TWS has been installed. If this is the case, it is important that, immediately after the TWS installation, before you login the first time, you remember to activate again the checkbox Use/Store Settings on Server on the login screen of the TWS. You can find more details here.

In this tutorial we describe the installation using Safari, which is installed by default on every Mac computer. If you prefer to use another browser (such as: Mozilla Firefox or Google Chrome) please take into account that the disposition and/or the content of the messages appearing during the first three steps might slightly differ.

How to install Offline TWS Latest:

  1. Open the page www.ibkr.com in your browser, then click on the menu Technology--> TWS Software

 

  1. Scroll down the page, until you find the button OFFLINE TWS LATEST. Click on it
    Offline TWS Latest Installation 
     
  1. Below Offline TWS Latest for Mac, click the button DOWNLOAD

  1. Click on your Download Folder to see list of available files. Double-click the disk image file tws-latest-standalone-macosx-x64.dmg 
    Download Folder - double-click tws-latest-standalone-macosx-x64.dmg
  1. The operating system will now mount the disk image file onto your desktop
    Wait till the tws disk image file mounts to your desktop
  1. Double-click the Trader Workstation icon to initiate the installerDouble-click the Trader Workstation icon to initiate the installer
  1. Click Open to confirm and start the installation for TWS
    Click Open to confirm and start installation
  1. The Installation Wizard will now initialize, click Next>
    TWS Installation Wizard - Next
     
  1. After the installation completes, click Finish
    TWS Installation Wizard - Click Finish
  1. A TWS icon will now appear on your desktop. Double-click it to launch the Login box. Please notice that the icon will inlclude the actual build number (Build) of the TWS you installed. Therefore you could see Trader Workstation 960 or Trader Workstation 961 etc.
    Click the TWS icon to launch TWS

Recovering your Settings

  1.  Launch the TWS. Once the login screen has loaded, tick the checkbox Use/Store Settings on ServerCheck the box "Use/Store Settings on Server"
     
  2. Enter your username and password and click Login. The TWS will now attempt to download your settings stored on the cloud and load them into the TWS

    Enter your username and password then proceed to login

Syndicate content