Paul Pluzhnikov <[EMAIL PROTECTED]> writes: STEVEN MARX wrote:
> Thanks for you help and time. Please follow up to newsgroup, rather than to personal e-mail, unless there is a reason to contact me privately. > Per my original question, this class compiles and runs without error but > does not appear to be deleting memory (using top to measure memory use). This class violates Item 11 of "Effective C++". I *urge* you to get that book, and read from start to end, before continuing. > > class Bitmapgrayscalescalable : public Command { > public: > int type, mode; > float xc, yc, bwd, bht; Classes generally should not publicly expose their implementation data (without a good reason). > char *bitdata; Ok, so you have a "pointer to array" as your member. > Bitmapgrayscalescalable(... > { > bitdata = new char[length]; > for(int i = 0; i < length; i++) > bitdata[i] = buffer[i]; > } Why not: bitdata = new char[length]; memcpy(bitdata, buffer, length); Memcpy will likely be more efficient on just about every platform. > ~Bitmapgrayscalescalable() { > delete [] bitdata; > } > }; There is nothing wrong with the above, provided you do not copy or assign any instances of that class. If you do, you have a serious heap corruption problem (see Item 11). However, since your "bitdata" member is public, perhaps someone assigns NULL to it prior to destruction? That would explain the leak. You can also try to create a minimal self-contained example, demonstrating the problem. > */Paul Pluzhnikov <[EMAIL PROTECTED]>/* wrote: A. Because doing so makes the conversation harder to read. Q. Why should I not top-post? Please do not top-post. Cheers, -- In order to understand recursion you must first understand recursion. Remove /-nsp/ for email. _______________________________________________ help-gplusplus mailing list help-gplusplus@gnu.org http://lists.gnu.org/mailman/listinfo/help-gplusplus