Recursive script calls cause huge Memory leaks that leads to machine / FMP Crash
FMS 13v4 / Filemaker 13v3
Operating system version
Mac OS 10.9.5
Description of the issue
Also happens on clients but much worse on server (hence the server classification : too bad we can't select both)
A Script that calls himself repeatedly (infinitely) will create a growing memory leak that will exhaust the mac memory (swapping space) to crash if ran as a server side processing script
OR will leak but will crash Filemaker Client much faster if ran on a client (at least standalone, didn't test remote hosting in that case).
Of course infinite recursive call is a due to a bug in the script the dev created. BUT, no program should lake memory and as Infinite calls definitely shows the problems, maybe some moderate normal / wished recursive calls creates a bit of leak that could grow and lead problems in the future.
Contrary to FMP Client, server will not crash before the whole system freezes (all memory exhausted) so the leaking will be much bigger than on client.
Steps to reproduce the problem
Create a recursive script that calls himself infinitely (maybe huge huge number works also), for instance
Set Variable [$t; Value:$t+1]
Perform Script [“Recursive_Script”]
Run this script on a client standalone (didn't test remote) OR as a server side processing script on FMS
Also, you can use the attached file I create (password is l : Admin, pastor is empty)
File : https://www.dropbox.com/s/qbd2eo0vd0snt3w/Leak.zip?dl=0
As client :
Run first script called "Recursive_Script" of the script menu, and watch the process eat memory before filemaker cash (which happens in 40 seconds on my mac).
On Server :
Create a server side processing schedule calling that script, UNCHECK the time limit. Launch that schedule with FMS admin. Leave it running for hours. Actually you'll see the memory usage of fmsased grow pretty fast. At some point the memory usage in the Process monitor of Mac OS X will be huge but stable but in fact, swapping fils will still grow (you can monitor those swapping file by using the command ls -l /private/var/vm from time to time).
**** IMPORTANT : ON SERVER mavericks RAM COMPRESSION feature had been DISABLED by the command ****
sudo nvram boot-args="vm_compressor=1"
(I did this to troubleshoot other issue. I've yet to test on server with Ram Compression on (not sure I'll have the time to), so I'm not sure it also happens on server with RC ON. But if that's not the case, maybe ram compression hides the problems but can compromise server stability. However, on client, which crashed a lot faster RC was ON as default).
Huge CPU consumption, but stable and moderate memory consumption, without memory leaks and Without crash
Memory usage, and especially Virtual memory of the process grows till it exhaust all disk space if ran on a server as server side processing.
Ballooning memory usage on client for 40 seconds then Filemaker crash (before all disk space is exhausted)
Exact text of any error message(s) that appear
No message from filemaker (aside when mac hosting the server crashed, then disconnects message on client)
On server with server side processing
08/10/2014 02:54:27,000 kernel: (default pager): [KERNEL]: ps_allocate_cluster - send HI_WAT_ALERT
08/10/2014 02:54:27,000 kernel: macx_swapon FAILED - 12
08/10/2014 02:55:02,000 kernel: (default pager): [KERNEL]: ps_select_segment - send HI_WAT_ALERT
08/10/2014 02:55:02,000 kernel: (default pager): [KERNEL]: System is out of paging space.
Command top returns
863 fmsased 2.8 01:55:27 22 1 80 31086 5245M- 10G- 0B 0B 53G 56G 132 132 stuck 503 15998448+ 726
862 fmserverd 3.6 53:52.34 71 1 137 2012 633M- 1094M- 0B 0B 7859M 10G 861 1 stuck 503 2351272 646
ls -l /private/var/vm will show a lot of swapping files
For Server : Macbook pro 2012 15" 2.7 GHhz core i7 16GB of RAM (8GB allowed as cache for FMS) 10.9.5
For client : Macbook pro 2010 15" 2.66 Ghz core i7 16GB of RAM (8GB allowed as cache for FMS) 10.9.5
None (aside the obvious controlling the recursion better so it's not infinite).