Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 677 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Memory leak in Strategy Test #467897
09/06/17 11:46
09/06/17 11:46
Joined: Aug 2017
Posts: 58
P
pascalx Offline OP
Junior Member
pascalx  Offline OP
Junior Member
P

Joined: Aug 2017
Posts: 58
I get Error 060: Memory fragmented / limit exceeded regularly when testing a few strategies. Zorro can have a strategy that, let's say, allocates 800 MB in one test run. Now if you happen to run 3 other strategies afterwards with 800 MB each too, then you already crash Zorro. There is no memory cleanup after a test run, so it just takes a few scripts to exceed the memory limit.

Consider this script and create 4 instances of it. Use the Zorro M1 history data. Run each script once. Zorro will run out of memory.

Code:
void run()
{
	set(TICKS);
	NumYears = 10;
	string currentAsset;
	while(currentAsset=loop("EUR/USD", "XAU/USD", "USD/JPY", "USD/CAD", "GBP/USD", "AUD/USD", "NAS100", "SPX500"))
		asset(currentAsset);
}



The expectation is that Zorro cleans up after a test run. There is only a cleanup if you retest a strategy.

Summary:
Hit "Test" once, hit "Test" again -> memory cleans up.
Hit "Test" once, change strategy, hit "Test again -> no memory clean up

Attached Files error.png
Last edited by pascalx; 09/06/17 11:47.
Re: Memory leak in Strategy Test [Re: pascalx] #467899
09/06/17 17:24
09/06/17 17:24
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
Can confirm. I have repeated this error in Zorro S 1.61.6, having compiled this strategy in DLL form (attached).

Attached Files
bug001.dll.zip (265 downloads)
bug001.dll
Re: Memory leak in Strategy Test [Re: AndrewAMD] #467907
09/07/17 11:55
09/07/17 11:55
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
That's mentioned in the manual. There is no "clean up". It's no leak, but simply fragmented memory. You must restart. No way around. It does not matter if your strategy is C or DLL.

Re: Memory leak in Strategy Test [Re: jcl] #467910
09/07/17 13:36
09/07/17 13:36
Joined: Aug 2017
Posts: 58
P
pascalx Offline OP
Junior Member
pascalx  Offline OP
Junior Member
P

Joined: Aug 2017
Posts: 58
But that is a flaw in the programs memory design, isn't it? After all, only the program logic is responsible for storing data on the heap. If the allocator(s) don't organize the given data according to their lifetime, then you end up with fragmentation. But given that a test run has a known lifetime, it should be very well possible to organize the allocations serving that specific test run appropriately.

Re: Memory leak in Strategy Test [Re: pascalx] #467912
09/07/17 14:45
09/07/17 14:45
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
A fixed memory allocation order could indeed overcome fragmentation. But this is extremely hard to implement, if possible at all, and would probably require a large amount of reallocation at runtime with all the negative consequences on speed. This is not planned at this point.

Re: Memory leak in Strategy Test [Re: jcl] #467913
09/07/17 15:57
09/07/17 15:57
Joined: Aug 2017
Posts: 58
P
pascalx Offline OP
Junior Member
pascalx  Offline OP
Junior Member
P

Joined: Aug 2017
Posts: 58
Considering this company is developing a game engine I would assume it has appropriate bucket allocators to perform this task. If the engine unloads a game level it also cleans up its contents without crashing the game after a few level loads, right?

Re: Memory leak in Strategy Test [Re: pascalx] #467928
09/08/17 07:37
09/08/17 07:37
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
Indeed. I had not thought about that. The Acknex engine uses a special preallocated memory management for avoiding that the game runs out of memory at level change. This would probably solve the fragmentation problem. I`ve made a notice to consider this for a future update.

Re: Memory leak in Strategy Test [Re: jcl] #467934
09/08/17 14:24
09/08/17 14:24
Joined: Aug 2017
Posts: 58
P
pascalx Offline OP
Junior Member
pascalx  Offline OP
Junior Member
P

Joined: Aug 2017
Posts: 58
Thanks bro.


Moderated by  Petra 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1