Here is a code for create and delete a 3D array!
when i try to catch memory leak by the following code, It alerts that i have exactly 1600 bytes memory leak!
Where is the problem of my Code?
#define VAR_TYPE double
VAR_TYPE ** Create2Darray(int n, int l)
VAR_TYPE **temp = new VAR_TYPE*[n];
for (int i =0 ; i< n ; i++) temp[i] = new VAR_TYPE[l];
VAR_TYPE *** Create3DArray(int x,int y,int z)
VAR_TYPE *** arrayd;
arrayd = new VAR_TYPE**[x];
for (int i =0 ; i< x ; i++) arrayd[i] = Create2Darray(y,z);
void Delete3DArray(VAR_TYPE *** darray,int Xdim,int Ydim,int Zdim)
for (int k =0; k<Xdim;k++)
for (int j=0; j<Ydim;j++)
delete  darray[k][j];
delete  darray[k];
darray[k] = NULL;
delete  darray;
darray = NULL;
//code for detect memory leak#ifdef _DEBUG
CMemoryState msOld,msnew, diffMemState;
double *** Sample_Temp = Create3DArray(182,218,182);
Delete3DArray(Sample_Temp,182, 218, 182);
if( diffMemState.Difference(msOld, msnew) )
TRACE( "Memory leaked!\n" );
the output ofter running diffMemState.DumpStatistics() :
0 bytes in 0 Free Blocks.
120 bytes in 2 Normal Blocks.
0 bytes in 0 CRT Blocks.
0 bytes in 0 Ignore Blocks.
0 bytes in 0 Client Blocks.
Largest number used: 57659956 bytes.
Total allocations: 57661556 bytes.
The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.
- John Carmack
It's probably a third party macro or something similar.
I remember having written a program that parses all .CPP and .H files in a folder and its sub-folders to check for syntax. It even did a little formatting.
«_Superman_» I love work. It gives me something to do between weekends.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
Fisrt, I must say that my first language is not English, so my English is poor and maybe the article is hard to understand. But I will try my best to descript it.
When I used the "CListCtrl" and "Windows Media Player Control" in MFC under Visual Studio 6.0, a strange problem occured.
CWMPMedia media = m_wmpplayer.GetCurrentMedia();
for (int i = 0; i < 5; i++)
m_playlist.InsertItem(LVIF_TEXT | LVIF_STATE, i, media.getItemInfo("Name"), 0, LVIS_SELECTED, 0, 0);
CString strBitRate = media.getItemInfo("BitRate");
int nBitRate = atoi(strBitRate.GetBuffer(strBitRate.GetLength()));
strBitRate.Format(_T("%dKbps"), nBitRate / 1000);
m_playlist.SetItemText(i, 1, media.getItemInfo("author"));
m_playlist.SetItemText(i, 2, strBitRate);
m_playlist.SetItemText(i, 3, m_wmpplayer.GetUrl());
When I run the above code, the bitrate of the CListCtrl's list items' is 0kbps and the "author" is empty.
But if I call the MessageBox function in the for-loop, the result is correct. The bitrate will be the fact bitrate and the author will also not be empty.
I really cannot understand why this condition could happen.
It would be a honor to me If you can help me solve this problem.
Thank you very much.
I'd like to write a C++ app program that would store a list of files (by relative path/location) plus it's CRC32 or checksum. Then it would also store more CRC32/checksums for the same file, for each snapshot in time.
The main usage of the app would be to help identify which versions of the current folder contents are.
Does anyone know such program already exist? If not, how to write in C++ with common libraries (boost, etc)?
Last Visit: 31-Dec-99 19:00 Last Update: 27-Nov-21 13:43