stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Travis Vitek (JIRA)" <j...@apache.org>
Subject [jira] Commented: (STDCXX-577) purify reports leaked memory in stocks example
Date Thu, 10 Jan 2008 00:53:34 GMT

    [ https://issues.apache.org/jira/browse/STDCXX-577?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12557496#action_12557496
] 

Travis Vitek commented on STDCXX-577:
-------------------------------------

The leaks mentioned by the valgrind report are potential leaks in purify. The locale that
is imbued on std::cout.rdbuf() owns a StockXchange facet that is allocated on the heap. If/When
the locale is destroyed, the facet reference count would be decremented and the object would
be deallocated [if appropriate].

My solution is to restore the streams locale before main returns. This prevents the facet
from being in use at program termination. This fix is included in the above patch.

> purify reports leaked memory in stocks example 
> -----------------------------------------------
>
>                 Key: STDCXX-577
>                 URL: https://issues.apache.org/jira/browse/STDCXX-577
>             Project: C++ Standard Library
>          Issue Type: Improvement
>          Components: Examples
>    Affects Versions: 4.2.0
>            Reporter: Travis Vitek
>            Assignee: Travis Vitek
>             Fix For: 4.2.1
>
>         Attachments: stdcxx-577.patch, stocks-valgrind.log, stocks.log
>
>
> It is pretty obvious from looking at the source that memory is being leaked. The destructor
for StockXchange doesn't deallocate memory allocated in StockXchange::add(), and the sl_pairs
allocated in main are never deallocated.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message