Dukascopy
 
 
Wiki JStore Search Login

Attention! Read the forum rules carefully before posting a topic.

    Submit JForex API bug reports in this forum only.
    Submit Converter issues in Converter Issues.
    Off topics are strictly forbidden.

Any topics which do not satisfy these rules will be deleted.

App slows down after running strategy several times
 Post subject: App slows down after running strategy several times Post rating: 0   New post Posted: Thu 07 Apr, 2016, 03:23 
User avatar

User rating: 0
Joined: Fri 10 Oct, 2014, 02:09
Posts: 27
Location: Vietnam,
I wrote an app that uses the JForex API to run the same strategy in a loop. After several iterations, the app starts slowing down. Sometimes it takes longer to happen. Sometimes it happens faster but once the app starts slowing down, it slows down quickly. It always happens. It looks as if there is resource leak somewhere. Has anyone else seen this behavior? Is there a workaround?

PS: It looks like the amount of data processed has an impact on how soon the slow-down happens. If I run the strategy over a longer time span, say a year versus a month, then it takes fewer iterations for the slow-down to happen.


 
 Post subject: Re: App slows down after running strategy several times Post rating: 0   New post Posted: Thu 07 Apr, 2016, 15:58 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
This usually happens when strategy object contains references to a growing number of objects. Hence, the memory gets full.
We would suggest not to store any global variables or large amounts of tick/bar data.


 
 Post subject: Re: App slows down after running strategy several times Post rating: 0   New post Posted: Fri 08 Apr, 2016, 08:29 
User avatar

User rating: 0
Joined: Fri 10 Oct, 2014, 02:09
Posts: 27
Location: Vietnam,
A new instance of the strategy is created in each iteration so memory usage should not grow with the number of iterations. My app does maintain a data cache but its size is less than 200K so it should not be causing memory issues. I am thinking more along the line of resource leakage, like files not being closed properly.

One other observation that might be helpful: If I restart my app and transfer the cache to the new instance, the app runs fast again. So it is definitely not an issue with the cache taking too much memory. My app doesn't hold on to any other data so the problem seems to be with the JForex client library.

I ran my app on a high memory machine and the slow-down still happens at a similar frequency so it doesn't look like a memory issue as much as a system resource issue. Please check to make sure the client library is releasing system resources cleanly.

One scenario that can cause resource leakage that I have seen happen quite often is opening a file stream and then while reading data an exception is thrown and the file stream is never closed. I use the following code snippet to make sure file streams are always closed properly:

FileInputStream fis = null;

try {
// do things

} catch (Exception e) {
throw e;

} finally {
if (null != fis) {
try { fis.close(); }
catch (Exception e) {}
}
}


 

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