06/08/13 13:55, David Matthews wrote:
On 04/08/2013 22:31, Dmitry Popoinikov wrote:
Hi, David
Thank you for response. Yes I 'translate' multithreading C application to Poly/ML (and it crashes in these callbacks) and I thought I do something wrong.
Let me ask you one more question? Whether you recommend to use Poly/ML for programs working in a mode 7/24? (Whether it is possible to be sure of that the memory expense never will exceed --maxheap?)
Hi Dmitry, I can't see there would be any problem with running a Poly/ML program for a long time. Provided your application only requires a constant data size there's no reason why the heap should grow beyond a steady state. There will be periodic garbage collections of course.
There was a previous discussion here starting on 2012-01-27 entitled "Lifespan of pointers to callback functions passed via C FFI" where it was noted that a callback is never garbage collected and a new callback object is created each time the ML callback conversion is evaluated. The previous discussion can be found in the list archives for the following months: http://lists.inf.ed.ac.uk/pipermail/polyml/2012-January/thread.html http://lists.inf.ed.ac.uk/pipermail/polyml/2012-February/thread.html http://lists.inf.ed.ac.uk/pipermail/polyml/2012-August/thread.html
So it appears that the heap could grow arbitrarily large, albeit very slowly, if there is no upper bound on the number of callbacks constructed. I suspect that this can be avoided by writing SML to ensure that only one callback is constructed for each SML function passed via the FFI.
Regards, Phil