Re: memory leak?
- From: Joseph M. Newcomer <newcomer@xxxxxxxxxxxx>
- Date: Mon, 30 Jul 2007 09:47:31 -0400
See below...I agree completely
On Mon, 30 Jul 2007 12:39:59 +0200, "Giovanni Dicanio" <giovanni.dicanio@xxxxxxxxxx>
wrote:
****
"Dani" <anonymous@xxxxxxxxxxxxxxxxxxxxxxxxx> ha scritto nel messaggio
news:uXXGN3c0HHA.5152@xxxxxxxxxxxxxxxxxxxxxxx
[...]
But do not assume that you have solved your problem, you should
investigate this memory leak deeply before you continue with writing your
program.
I completely agree.
Moreover, I wonder why the OP is using malloc/free (or even new/delete),
when he could instead use the more robust C++ container classes like
std::vector or MFC containers. If he wants to allocate an array of bytes to
store his video stream data, he could use std::vector<BYTE> or MFC container
CByteArray.
I essentailly consider any situation in which the malloc/new and delete/free happen in the
same function to be poor C++ coding style. I always use something like CByteArray. Key
here is to know that GetData gives a pointer the actual data.
****
****
And, as Doug pointed in several of his previous posts in these newsgroups,
smart pointers like std::auto_ptr are good tools to fight against memory
leaks...
Moreover, frankly speaking, I don't like very much the use 'char' to
identify a 'byte'. IMHO, the code would be more readable and robust if an
explicit BYTE identifier is used, instead of 'char' (I don't know if the C++
standard states that a 'char' is an 8-bits byte... but I would always prefer
the explicit 'byte' specification instead of 'char'...).
One of the problems with using 'char' is that it is confusing if the application is
supposed to be Unicode-aware; 'char' is a signed 8-bit quantity which is occasionally used
to represent character data, and that is confusing, because mostly characters are now
thought of as TCHAR values (signed character values representing code points) and the
presence of other 'char' values that have nothing to do with representing strings lends
confusion. So I, too, insist on using BYTE to represent 8-bit quantities, and more so
because these are rarely signed values.
joe
*****
Joseph M. Newcomer [MVP]
Giovanni
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.
- Follow-Ups:
- Re: memory leak?
- From: Doug Harrison [MVP]
- Re: memory leak?
- References:
- memory leak?
- From: wanwan
- Re: memory leak?
- From: Joseph M . Newcomer
- Re: memory leak?
- From: Doug Harrison [MVP]
- Re: memory leak?
- From: wanwan
- Re: memory leak?
- From: Doug Harrison [MVP]
- Re: memory leak?
- From: wanwan
- Re: memory leak?
- From: Dani
- Re: memory leak?
- From: Giovanni Dicanio
- memory leak?
- Prev by Date: Re: Need help solving a threading issue
- Next by Date: Re: Need help solving a threading issue
- Previous by thread: Re: memory leak?
- Next by thread: Re: memory leak?
- Index(es):
Relevant Pages
|