[Freeswitch-users] Memory allocation "switch_core_session_alloc"

Ahmed habiba ahabiba at gmail.com
Thu Mar 31 22:17:17 MSD 2016


Mainly I’m not writing a new module, I’m modifying mod_spy to allow spying current active called without providing uuid, mainly I did the below:
1-Creat new hash map to contain all bridged calls(userid at domain as key, and UUID as value).
2-when I receive any spy request I query the hash map, using userid at domain, if I find a uuid and add it as if I get it in command “userspy userid at domain uuid “
3-then I continue.

The point that I try to allocate the memory on session level and once the call get hangup I remove it from the hash map, however this doesn’t work as I expect only one hangup request comes and accordingly one entry from hasp being removed.

I attached here the code for your review



From: Anthony Minessale <anthony.minessale at gmail.com <mailto:anthony.minessale at gmail.com>>
Subject: Re: [Freeswitch-users] Memory allocation "switch_core_session_alloc"
Date: March 31, 2016 at 1:51:48 AM GMT+3
To: FreeSWITCH Users Help <freeswitch-users at lists.freeswitch.org <mailto:freeswitch-users at lists.freeswitch.org>>
Reply-To: FreeSWITCH Users Help <freeswitch-users at lists.freeswitch.org <mailto:freeswitch-users at lists.freeswitch.org>>


Correct.  The memory is allocated from the session's pool and will not be valid when the call ends.

For persistent memory allocation, create your own pool when the module loads, (or use the one passed to you in the init function) and use switch_core_alloc instead.

What module are you writing?



On Wed, Mar 30, 2016 at 4:48 PM, Ahmed habiba <ahabiba at gmail.com <mailto:ahabiba at gmail.com>> wrote:
Hi,

I’m trying to use “switch_core_session_alloc” in a new module however I notice in documentation the below note, does this mean that once the session hangup this memory segment will not be valid anymore and I should not use this segment again?, your kind feedback will be appreciated.

"Note:
the memory will be in scope as long as the session exists"


Thanks,

Ahmed Habiba.

_________________________________________________________________________
Professional FreeSWITCH Consulting Services:
consulting at freeswitch.org <mailto:consulting at freeswitch.org>
http://www.freeswitchsolutions.com <http://www.freeswitchsolutions.com/>

Official FreeSWITCH Sites
http://www.freeswitch.org <http://www.freeswitch.org/>
http://confluence.freeswitch.org <http://confluence.freeswitch.org/>
http://www.cluecon.com <http://www.cluecon.com/>

FreeSWITCH-users mailing list
FreeSWITCH-users at lists.freeswitch.org <mailto:FreeSWITCH-users at lists.freeswitch.org>
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users <http://lists.freeswitch.org/mailman/listinfo/freeswitch-users>
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users <http://lists.freeswitch.org/mailman/options/freeswitch-users>
http://www.freeswitch.org <http://www.freeswitch.org/>



-- 
Anthony Minessale II       ♬ @anthmfs  ♬ @FreeSWITCH  ♬

☞ http://freeswitch.org/ <http://freeswitch.org/>  ☞ http://cluecon.com/ <http://cluecon.com/>  ☞ http://twitter.com/FreeSWITCH <http://twitter.com/FreeSWITCH>
☞ irc.freenode.net <http://irc.freenode.net/> #freeswitch ☞ http://freeswitch.org/g+ <http://freeswitch.org/g+>

ClueCon Weekly Development Call 
☎ sip:888 at conference.freeswitch.org <mailto:sip%3A888 at conference.freeswitch.org>  ☎ +19193869900 

https://www.youtube.com/watch?v=9XXgW34t40s <https://www.youtube.com/watch?v=9XXgW34t40s>
https://www.youtube.com/watch?v=NLaDpGQuZDA <https://www.youtube.com/watch?v=NLaDpGQuZDA>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20160331/f7dc206b/attachment-0002.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mod_spy.c
Type: application/octet-stream
Size: 16670 bytes
Desc: not available
Url : http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20160331/f7dc206b/attachment-0001.obj 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20160331/f7dc206b/attachment-0003.html 


Join us at ClueCon 2016 Aug 8-12, 2016
More information about the FreeSWITCH-users mailing list