[OpenSER-Devel] RFC: memory management in database modules

Daniel-Constantin Mierla daniel at voice-system.ro
Fri Feb 8 16:21:46 UTC 2008


Hello Henning,

On 02/08/08 15:44, Henning Westerholt wrote:
> On Tuesday 05 February 2008, Daniel-Constantin Mierla wrote:
>   
>>> [..]
>>> postgres, db_berkeley allocate new memory and copy all string values from
>>> the database to the internal representation. Modules that uses this
>>> driver don't need to copy there values, even after the freeing of the
>>> result set.
>>>       
>> quite strange, if the copy is not freed with free_result(), when it
>> happens? At first thought, seems exposed to memory leak.
>>
>> db_berkely seems constructed on dbtext structure. In dbtext, the result
>> is duplicated in private memory, as the tables are stored in shared
>> memory, and making direct references will be exposed to race.
>>     
>
> Hi Daniel,
>
> could you point me to the position in the db_text module where the result is 
> duplicated? Are only the STR, STRING and BLOB values duplicated, and thus 
> must be later freed, or all values that are definied in db_type_t?
>   
the string-type values are re-allocated in pkg (they reside in shm):

See dbt_res.c, starting with line 230, in function 
dbt_result_extract_fields()

Cheers,
Daniel

> Thank you,
>
> Henning
>
>   



More information about the Devel mailing list