Dukascopy
 
 
Wiki JStore Search Login

JFOREX-2356 Java heap space out of memory error with tester
 Post subject: JFOREX-2356 Java heap space out of memory error with tester Post rating: 0   New post Posted: Fri 22 Oct, 2010, 10:17 

User rating: 0
Joined: Mon 27 Sep, 2010, 13:19
Posts: 6
Hello support,

with our tester, based on ITesterClient and testerfactory, we were testing strategies successfully over the last few weeks.

Now, as we have a new, more complex strategy, we get an error message after a while, because od GC overhead limit exceeded.

Quote:
2010-10-21 21:45:50.905 ERROR t - GC overhead limit exceeded
java.lang.OutOfMemoryError: GC overhead limit exceeded
at java.util.Arrays.copyOf(Unknown Source)
at java.util.ArrayList.ensureCapacity(Unknown Source)
at java.util.ArrayList.add(Unknown Source)
at java.util.regex.Pattern.split(Unknown Source)
at java.lang.String.split(Unknown Source)
at java.lang.String.split(Unknown Source)
at StratTester.LabelInformation.getLastOpenLong(dailyProfitV100.java:272)
at StratTester.Cascade.<init>(dailyProfitV100.java:432)
at StratTester.dailyProfitV100.onTick(dailyProfitV100.java:93)
at com.dukascopy.dds2.greed.agent.strategy.tester.t.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Strategy tester: java.lang.OutOfMemoryError: GC overhead limit exceeded @ StratTester.dailyProfitV100.onTick(dailyProfitV100.java:93)
GC overhead limit exceeded: java.lang.OutOfMemoryError: GC overhead limit exceeded
at java.util.Arrays.copyOf(Unknown Source)
at java.util.ArrayList.ensureCapacity(Unknown Source)
at java.util.ArrayList.add(Unknown Source)
at java.util.regex.Pattern.split(Unknown Source)
at java.lang.String.split(Unknown Source)
at java.lang.String.split(Unknown Source)
at StratTester.LabelInformation.getLastOpenLong(dailyProfitV100.java:272)
at StratTester.Cascade.<init>(dailyProfitV100.java:432)
at StratTester.dailyProfitV100.onTick(dailyProfitV100.java:93)
at com.dukascopy.dds2.greed.agent.strategy.tester.t.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
2010-10-21 21:45:50.912 ERROR TesterClientImpl$b - Exception thrown while running onTick method: GC overhead limit exceeded
java.lang.OutOfMemoryError: GC overhead limit exceeded
at java.util.Arrays.copyOf(Unknown Source)
at java.util.ArrayList.ensureCapacity(Unknown Source)
at java.util.ArrayList.add(Unknown Source)
at java.util.regex.Pattern.split(Unknown Source)
at java.lang.String.split(Unknown Source)
at java.lang.String.split(Unknown Source)
at StratTester.LabelInformation.getLastOpenLong(dailyProfitV100.java:272)
at StratTester.Cascade.<init>(dailyProfitV100.java:432)
at StratTester.dailyProfitV100.onTick(dailyProfitV100.java:93)
at com.dukascopy.dds2.greed.agent.strategy.tester.t.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
2010-10-21 21:46:01.701 INFO MyTesterMain - Strategy stopped: 1
2010-10-21 21:46:01.827 DEBUG CacheManager - Reading ticks from chunk file [C:\Users\os\AppData\Local\Temp\.cache\EURAUD\2009\10\24\21h_ticks.bi5]
2010-10-21 21:46:01.827 DEBUG CacheManager - Reading ticks from chunk file [C:\Users\os\AppData\Local\Temp\.cache\AUDUSD\2009\10\24\21h_ticks.bi5]
2010-10-21 21:46:01.827 DEBUG CacheManager - Reading ticks from chunk file [C:\Users\os\AppData\Local\Temp\.cache\EURUSD\2009\10\24\21h_ticks.bi5]
2010-10-21 21:46:39.272 DEBUG CacheManager - Reading ticks from chunk file [C:\Users\os\AppData\Local\Temp\.cache\NZDUSD\2009\10\24\23h_ticks.bi5]
2010-10-21 21:46:39.339 DEBUG DCClientImpl - Strategy execution progress: Running, 2009.11.24 21:00 Eq: 5,76 UoL: 0%
2010-10-21 21:46:48.016 DEBUG CacheManager - Reading ticks from chunk file [C:\Users\os\AppData\Local\Temp\.cache\AUDUSD\2009\10\24\22h_ticks.bi5]
2010-10-21 21:47:16.202 DEBUG CacheManager - Reading ticks from chunk file [C:\Users\os\AppData\Local\Temp\.cache\AUDNZD\2009\10\24\22h_ticks.bi5]
2010-10-21 21:47:16.235 DEBUG DCClientImpl - Strategy execution progress: Running, 2009.11.24 21:30 Eq: 5,76 UoL: 0%
2010-10-21 21:47:16.330 DEBUG CacheManager - Reading ticks from chunk file [C:\Users\os\AppData\Local\Temp\.cache\EURAUD\2009\10\24\22h_ticks.bi5]
2010-10-21 21:47:16.330 DEBUG CacheManager - Reading ticks from chunk file [C:\Users\os\AppData\Local\Temp\.cache\AUDNZD\2009\10\24\23h_ticks.bi5]
2010-10-21 21:47:42.406 ERROR t - GC overhead limit exceeded
java.lang.OutOfMemoryError: GC overhead limit exceeded
at java.math.BigInteger.pow(Unknown Source)
at java.math.BigDecimal.<init>(Unknown Source)
at StratTester.Misc.risk(dailyProfitV100.java:1229)
at StratTester.Cascade.initializeAndRepairCascade(dailyProfitV100.java:524)
at StratTester.dailyProfitV100.onTick(dailyProfitV100.java:85)
at com.dukascopy.dds2.greed.agent.strategy.tester.t.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Strategy tester: java.lang.OutOfMemoryError: GC overhead limit exceeded @ StratTester.dailyProfitV100.onTick(dailyProfitV100.java:85)
GC overhead limit exceeded: java.lang.OutOfMemoryError: GC overhead limit exceeded2010-10-21 21:47:42.406 ERROR TesterClientImpl$b - Exception thrown while running onTick method: GC overhead limit exceeded
java.lang.OutOfMemoryError: GC overhead limit exceeded
at java.math.BigInteger.pow(Unknown Source)
at java.math.BigDecimal.<init>(Unknown Source)
at StratTester.Misc.risk(dailyProfitV100.java:1229)
at StratTester.Cascade.initializeAndRepairCascade(dailyProfitV100.java:524)
at StratTester.dailyProfitV100.onTick(dailyProfitV100.java:85)
at com.dukascopy.dds2.greed.agent.strategy.tester.t.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

at java.math.BigInteger.pow(Unknown Source)
at java.math.BigDecimal.<init>(Unknown Source)
at StratTester.Misc.risk(dailyProfitV100.java:1229)
at StratTester.Cascade.initializeAndRepairCascade(dailyProfitV100.java:524)
at StratTester.dailyProfitV100.onTick(dailyProfitV100.java:85)
at com.dukascopy.dds2.greed.agent.strategy.tester.t.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
2010-10-21 21:47:53.205 DEBUG CacheManager - Reading ticks from chunk file [C:\Users\os\AppData\Local\Temp\.cache\EURUSD\2009\10\24\22h_ticks.bi5]
2010-10-21 21:48:29.932 DEBUG DCClientImpl - Strategy execution progress: Running, 2009.11.24 22:00 Eq: 5,76 UoL: 0%
2010-10-21 21:48:30.017 DEBUG CacheManager - Reading ticks from chunk file [C:\Users\os\AppData\Local\Temp\.cache\EURAUD\2009\10\24\23h_ticks.bi5]
2010-10-21 21:48:38.744 DEBUG CacheManager - Reading ticks from chunk file [C:\Users\os\AppData\Local\Temp\.cache\AUDUSD\2009\10\24\23h_ticks.bi5]
Exception in thread "StrategyRunner Thread" java.lang.OutOfMemoryError: GC overhead limit exceeded
at java.lang.StringBuilder.toString(Unknown Source)
at java.math.BigDecimal.getValueString(Unknown Source)
at java.math.BigDecimal.toPlainString(Unknown Source)
at com.dukascopy.dds2.greed.agent.strategy.tester.q.a(Unknown Source)
at com.dukascopy.api.impl.connect.TesterClientImpl.a(Unknown Source)
at com.dukascopy.api.impl.connect.TesterClientImpl$a.a(Unknown Source)
at com.dukascopy.dds2.greed.agent.strategy.tester.t.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
2010-10-21 21:48:56.109 DEBUG DCClientImpl - Strategy execution progress: Running, 2009.11.24 22:30 Eq: 5,76 UoL: 0%
2010-10-21 21:49:07.372 DEBUG CacheManager - Reading ticks from chunk file [C:\Users\os\AppData\Local\Temp\.cache\EURUSD\2009\10\24\23h_ticks.bi5]
2010-10-21 21:49:07.574 DEBUG CacheManager - Reading ticks from chunk file [C:\Users\os\AppData\Local\Temp\.cache\EURUSD\2009\10\25\00h_ticks.bi5]
2010-10-21 21:49:07.608 DEBUG CacheManager - Reading ticks from chunk file [C:\Users\os\AppData\Local\Temp\.cache\NZDUSD\2009\10\25\00h_ticks.bi5]
2010-10-21 21:49:07.609 DEBUG DCClientImpl - Strategy execution progress: Running, 2009.11.24 23:00 Eq: 5,76 UoL: 0%
2010-10-21 21:49:25.239 DEBUG CacheManager - Reading ticks from chunk file [C:\Users\os\AppData\Local\Temp\.cache\AUDNZD\2009\10\25\00h_ticks.bi5]
2010-10-21 21:49:25.239 DEBUG CacheManager - Reading ticks from chunk file [C:\Users\os\AppData\Local\Temp\.cache\AUDUSD\2009\10\25\00h_ticks.bi5]
Exception in thread "StrategyRunner Thread" java.lang.OutOfMemoryError: GC overhead limit exceeded
at java.util.Arrays.copyOf(Unknown Source)
at java.util.ArrayList.toArray(Unknown Source)
at java.util.ArrayList.<init>(Unknown Source)
at com.dukascopy.dds2.greed.agent.strategy.tester.o.a(Unknown Source)
at com.dukascopy.dds2.greed.agent.strategy.tester.o.a(Unknown Source)
at com.dukascopy.dds2.greed.agent.strategy.tester.o.p(Unknown Source)
at com.dukascopy.dds2.greed.agent.strategy.tester.o.l(Unknown Source)
at com.dukascopy.dds2.greed.agent.strategy.tester.o.wQ(Unknown Source)
at com.dukascopy.dds2.greed.agent.strategy.tester.t.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)


However, I use a JForex.jnlp with a max heap size of 12000GB, which is fully used during the tests. So, I don't understand, why the heap space should be occupied so quickly.

Here is the code of my tester method:

    // Die TestMethode
public static void TheTester(IStrategy Strategy, final long a, Calendar fromDate, Calendar toDate, final ClassReaderContent AllParameters) throws Exception {
   
    Set<Instrument> InsSet = new HashSet<Instrument>();
    final ITesterClient testClient;
    // Instanz des IClient Interface
   
    testClient = com.dukascopy.api.system.TesterFactory.getDefaultInstance();
   
    // Listener des IClient Interface
    testClient.setSystemListener ( new ISystemListener() {
        @Override
        public void onStart(long processId) {
            processId = a;
            LOGGER.info("Strategy started: " + processId);
        }
     
        public void onStop(long processId) {

            // Konsolenausgabe
            LOGGER.info("Strategy stopped: " + processId);
            // erstellung des HTML-Files
            File reportFile = new File("report" + processId + ".html");
           
           
            // erstellung des Reports
            try {
                testClient.createReport(processId, reportFile);

            } catch (Exception e) {
                LOGGER.error(e.getMessage(), e);
            }

            if ((testClient.getStartedStrategies().size() == 0) && (processId >= (AllCombinations.size()) - 8)) {
                                CreateDataFile(AllParameters);
                System.exit(0);
            }
        }

        @Override
        public void onConnect() {
            LOGGER.info("Connected");
        }

        @Override
        public void onDisconnect() {

        }
    } );
    LOGGER.info ( "verbinde..." );
   
    // verbinde mit Server
    testClient.connect ( jnlpUrl, userName, password );

    // 10 Sekunden auf Verbindung warten
    for ( int i = 0; i < 10 && !testClient.isConnected(); ++i ) {
      Thread.sleep ( 1000 );
    }

    // Fehlermeldung falls Verbindung nicht moeglich
    if ( !testClient.isConnected() ) {
        LOGGER.error ( "Unable to connect" );
        System.exit ( 1 );
    }
   
    for (Instrument curinst : AllParameters.getTimeAndIns().getPair()) {
        InsSet.add(curinst);
        if ((curinst.getPrimaryCurrency().toString() != "EUR") && (curinst.getSecondaryCurrency().toString() != "EUR")) {
            String NewPair1;
            NewPair1 = "EUR/" + curinst.getPrimaryCurrency().toString();
            if (Instrument.isInverted(NewPair1)) {
                NewPair1 = curinst.getPrimaryCurrency().toString() + "/EUR";
            }
            String NewPair2;
            NewPair2 = "EUR/" + curinst.getSecondaryCurrency().toString();
            if (Instrument.isInverted(NewPair2)) {
                NewPair2 = curinst.getSecondaryCurrency().toString() + "/EUR";
            }
            InsSet.add(Instrument.fromString(NewPair1));
            InsSet.add(Instrument.fromString(NewPair2));
           
        }
    }
   
    LOGGER.info ( "Fordere Waehrungspaare an..." );
 
    testClient.setSubscribedInstruments ( InsSet );
   
    File cacheDir = new File ( "lollipop" );   
    cacheDir.mkdir();
    testClient.setCacheDirectory ( cacheDir );
testClient.setDataInterval (  Period.TICK,
                                  null,
                                  null,
                                  fromDate.getTimeInMillis(),
                                  toDate.getTimeInMillis() );
    testClient.setInitialDeposit ( java.util.Currency.getInstance ( "EUR" ), 100000 );
    testClient.setLeverage ( 100 );
    testClient.setMCEquity ( 0 ); 
   
    testClient.setProcessingStatsEnabled  ( false );
    testClient.setEventLogEnabled         ( false );
    testClient.setGatherReportData        ( false );
    LOGGER.info ( "Strategietest startet..." );   

    testClient.startStrategy ( Strategy, new MyTestProgressListener() );
    while (testClient.getStartedStrategies().size() >= 4){Thread.sleep(500);}
}


Thanks in advance for any help.

Greetings

Carsten


 
 Post subject: Re: JFOREX-2356 Java heap space out of memory error with tes Post rating: 0   New post Posted: Tue 26 Oct, 2010, 08:08 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Carten_K wrote:
However, I use a JForex.jnlp with a max heap size of 12000GB

You are setting heap to 12 terabytes? Maybe this is the reason, java doesn't understand such a big amount and resets it to standard values.

We can give you only basic recommendations. Check, if you are not using getBars or getTicks with large periods. These functions load all bars/ticks in a memory. Check the line dailyProfitV100.java:272 from the logs. If there is no problems, please use a memory profiler to find out process utilizes all memory, i.e. run jvisualvm.exe from your jdk, capture a memory snapshot when you will get OOM exception and analyse it yourself or send it to us.


 
 Post subject: Re: JFOREX-2356 Java heap space out of memory error with tes Post rating: 0   New post Posted: Tue 26 Oct, 2010, 13:07 

User rating: 0
Joined: Mon 27 Sep, 2010, 13:19
Posts: 6
Thanks a lot for your answer. Indeed the problem might be within the strategy

I meant 12G, of course :)

The issue is not so much that this error appears; the issue is that it appears with the ITesterClient-based tester but not with the online tester. I guess that there are relevant differences in the testing process of these two.


 

Jump to:  

  © 1998-2025 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com