Page 1 of 1

Virtual memory leak?

PostPosted: Wed Nov 25, 2015 3:09 pm
by MiguelTasende
Hello,

I've been having some problems when I try to do multiple calls to "e_load_group". About the 94th or 96th time I call it I get:

e_alloc(): mmap failure.
ERROR: Can't allocate external memory buffer!


Finally I decided to investigate the problem, as it is now critical for the code I am developing. I ran "top" on a 2nd ssh console, and found that the problem seemed to be Virtual Memory. Physical free memory remains ok, but virtual memory used rises like crazy.
When it gets to 3071964 KB the program crashes and show the message above.

Searching on the web I found that many linux kernels give a limit of 3GB Virtual Memory to any process. That would be 3145728, which looks suspiciously consistent with the problem.
Anyway (it's not what this linux says, but who knows... hidden limits...?):
>>ulimit -v
> unlimited

In any case, every call to e_load_group increases (a lot) the amount of virtual memory in use. I made a new program that doesn't use e_load at all (it has some e_alloc though, and other esdk init functions). With that change virtual memory still increases, but now much less and, for the tests I have run, to acceptable boundaries (it still increases, so if I left my program running some time (minutes/hours) it may crash... so: still not good).

I am not an expert in C (or linux) memory management. Is there any way to free that memory?

I will write some simple (a "repeated Hello World") code to expose the problem and try to fix it, if possible, but any ideas are welcome (maybe I am doing something wrong, also).

Re: Virtual memory leak?

PostPosted: Wed Nov 25, 2015 8:37 pm
by jar
You are not doing anything wrong. I've seen this issue before and it is indeed a leak. The eSDK needs to include an e_unload_group call or something. 32MB is allocated per call. Eventually you get to your issue. The only workaround I can suggest now is to use persistent threads that never return and use a locking mechanism to exchange new data with the host.

Re: Virtual memory leak?

PostPosted: Mon Jan 18, 2016 8:00 pm
by olajep
Likely cause and solution:
viewtopic.php?f=48&t=3406#p16604

// Ola