Summary: | ASTERISK-16129: iax2-parser eating memory if not LOW_MEMORY set. | ||
Reporter: | Eric Dantie (edantie) | Labels: | |
Date Opened: | 2010-05-22 05:32:09 | Date Closed: | 2011-06-07 14:00:56 |
Priority: | Major | Regression? | No |
Status: | Closed/Complete | Components: | Channels/chan_iax2 |
Versions: | Frequency of Occurrence | ||
Related Issues: | |||
Environment: | Attachments: | ( 0) iaxcall.txt | |
Description: | I think there a problem in iax-parser.c: it's allocating more memory than it release when LOW_MEMORY is not set... It applies at least to all 1.6 up to trunk. Try to explain: I have added comments in iax_frame_free to see when it's adding a memory space to pool. like that at line 1192 of 1.6.2 svn: if (iax_frames->size < FRAME_CACHE_MAX_SIZE) { +++ ast_verb(3, "Adding new frame to cache %d (length:%d)\n",iax_frames->size, fr->afdatalen); and one comment in iax_frame_new, line 1105 if (fr->afdatalen >= datalen) { size_t afdatalen = fr->afdatalen; AST_LIST_REMOVE_CURRENT(list); iax_frames->size--; memset(fr, 0, sizeof(*fr)); fr->afdatalen = afdatalen; +++ ast_verb(3,"Got frame from cache! new size:%d\n",iax_frames->size); break; The extension is receiving an iax call and do another iax call recompile and start doing a iax call. What I've got is: -- Accepting AUTHENTICATED call from 172.16.222.1: > requested format = gsm, > requested prefs = (gsm|alaw), > actual format = alaw, > host prefs = (alaw|gsm), > priority = mine -- Executing [9006@fromiax:1] MSet("IAX2/lpa-1993", "__PHONENUMBER=9006") in new stack -- Executing [9006@fromiax:2] Dial("IAX2/lpa-1993", "IAX2/lpa:contactel@172.16.222.1/61010") in new stack -- Called lpa:contactel@172.16.222.1/61010 -- Call accepted by 172.16.222.1 (format alaw) -- Format for call is alaw -- IAX2/172.16.222.1:4569-864 is proceeding passing it to IAX2/lpa-1993 -- Adding new frame to cache 0 (length:160) -- Adding new frame to cache 0 (length:160) -- Adding new frame to cache 0 (length:160) -- Adding new frame to cache 0 (length:160) -- Adding new frame to cache 0 (length:160) -- Got frame from cache! new size:0 -- Adding new frame to cache 0 (length:160) Will attach full extension log The problem is that it trying to add 5 frames to spool without using it... I think there should be some locking in iax free to avoid the problem... | ||
Comments: | By: Russell Bryant (russell) 2010-06-03 15:43:57 This is not a bug. chan_iax2 uses a pool of threads for processing. You're seeing the frame cache populate across the thread pool, not leaks within a single thread. By: Eric Dantie (edantie) 2010-06-03 16:40:22 Sorry not agreed: if adding to cache, next call to iax_frame_free should increment the size of iax_frames which is not the case until 6 calls to the function. But it has allocated each time memory for the cache. Shouldn't it be : - IAX2/172.16.222.1:4569-864 is proceeding passing it to IAX2/lpa-1993 -- Adding new frame to cache 0 (length:160) -- Adding new frame to cache 1 (length:160) -- Adding new frame to cache 2 (length:160) -- Adding new frame to cache 3 (length:160) -- Adding new frame to cache 4 (length:160) -- Got frame from cache! new size:3 -- Adding new frame to cache 3 (length:160) By: Eric Dantie (edantie) 2010-06-03 16:44:45 Oops, I've understood: there are 5 threads... OK. By: Russell Bryant (russell) 2010-06-03 18:00:32 Yep, it's a thread-local cache |