|
Boost : |
Subject: [boost] Subject: Re: [shared_ptr] Where is the bug?
From: Kasra Nassiri\(Math & ComSci\) (kasra_n500_at_[hidden])
Date: 2008-10-03 05:25:49
Hi,
Well the bug is in the fact the when you allocated:
B* b = new X();
You have allocated an int extra, thus when you call:
delete b;
You are only destructing what was allocated by B, which cause a sizeof(int) bytes memory leak each time you do this.
Just use a virtual destructor on virtual ~B() ... and that would take care of it all.
With best regards
Kasra Nassiri
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk