OK, this is really strange. I cut code down to almost nothing and I am still getting the same error.
What I have here is a simple IMPORTed call to a C function(which does nothing). A main loop that calls it many times. Its basically a cut down version of how the main project runs.
Yet, if you run Task Manager, there is a memory leak and eventually the same crash occurs as in the larger project.
I can't see the problem, I think my limited C knowledge may be failing me here.

Any-ways, if you could download this project, run it with Task Manger visible, to observe the memory leak and wait for the crash.
Oh, you will need to change the include path in the 'cmp' command line option within the project options (Currently -I"C:\Users\Dad\Desktop\test2\src").
Thanks for your help.
[attachment deleted by admin]