Boost Users :
Subject: Re: [Boost-users] Memory deallocation concerning boost::bind, boost::asio and shared_ptr
From: Chris Cleeland (chris.cleeland_at_[hidden])
Date: 2016-05-17 08:41:55
On Tue, May 17, 2016 at 6:15 AM, Norman <kradepon_at_[hidden]> wrote:
> In my example, the bound handlers to the
> *ioService* (e.g. accepting a new connection) would be freed in runtime,
> the appropriate memory won't be reclaimed by the OS. So to do this
> i found the following solution:
> *Release unused heap memory under Linux in C/C++: int malloc_trim(size_t
> Simplified explained, this method releases unused memory from the heap to
> the OS, which
> is exactly what i've been searching for.
Note that in the documentation there is no guarantee that this will
actually do anything. A good example of where this may not have much of an
effect is when the heap gets fragmented, with a small remaining in-use
allocation sitting near the top of heap and unused space beneath it.
While I understand the perception issue you face with your customers, in my
experience you're far better in the long run to educate your customers or
provide tools to show the ACTUAL memory use by your application rather than
potentially thrashing the virtual memory system just to make things comport
with their erroneous expectations.
-- Chris Cleeland
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net