Virtual memory leak?

Discussion about Parallella (and Epiphany) Software Development

Moderators: amylaar, jeremybennett, simoncook

Virtual memory leak?

Postby MiguelTasende » Wed Nov 25, 2015 3:09 pm


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).
Posts: 51
Joined: Tue Jun 30, 2015 12:44 pm

Re: Virtual memory leak?

Postby jar » Wed Nov 25, 2015 8:37 pm

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.
User avatar
Posts: 295
Joined: Mon Dec 17, 2012 3:27 am

Re: Virtual memory leak?

Postby olajep » Mon Jan 18, 2016 8:00 pm

Likely cause and solution:

// Ola
_start = 266470723;
Posts: 140
Joined: Mon Dec 17, 2012 3:24 am
Location: Sweden

Return to Programming Q & A

Who is online

Users browsing this forum: No registered users and 6 guests