Click here to Skip to main content
15,913,941 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRegistry editor Pin
prathuraj12-Apr-07 0:16
prathuraj12-Apr-07 0:16 
AnswerRe: Registry editor Pin
Rajesh R Subramanian12-Apr-07 1:53
professionalRajesh R Subramanian12-Apr-07 1:53 
AnswerRe: Registry editor Pin
Roger Stoltz12-Apr-07 2:29
Roger Stoltz12-Apr-07 2:29 
AnswerRe: Registry editor Pin
Hamid_RT19-Apr-07 21:56
Hamid_RT19-Apr-07 21:56 
QuestionProblem with Mnemonics of a Group box Pin
sw@thi12-Apr-07 0:14
sw@thi12-Apr-07 0:14 
QuestionProblem in running Window service Pin
ArunkumarSundaravelu11-Apr-07 23:43
ArunkumarSundaravelu11-Apr-07 23:43 
AnswerRe: Problem in running Window service Pin
bob1697212-Apr-07 5:40
bob1697212-Apr-07 5:40 
QuestionMemory Leak Pin
Rassul Yunussov11-Apr-07 23:30
Rassul Yunussov11-Apr-07 23:30 
I use CImage class for working with bitmaps and noticed memory leak and can't understand the problem.
When i'm trying to change the content of bitmap by accessing the bytes - in different cases i see or not see memory leaks, however the code is same!

Here is the code:
<br />
UINT __cdecl CGNTGDALDlg::GNTClassificationFunction( LPVOID pParam )<br />
{<br />
	ThreadStruct* pStruct = (ThreadStruct*)pParam;<br />
	int n = pStruct->pDlg->m_Image.GetHeight();<br />
	int m = pStruct->pDlg->m_Image.GetWidth();<br />
	int LineLength = pStruct->pDlg->m_Image.GetPitch();<br />
	unsigned char* Bitmap = (unsigned char*)pStruct->pDlg->m_Image.GetBits();<br />
	Bitmap+=LineLength*pStruct->Offset;<br />
	if(pStruct->pDlg->m_floatingWindowSize==0)<br />
	{<br />
		__declspec(align(16)) float* pInputs =(float*) _aligned_malloc(pStruct->pDlg->m_poDataset->GetRasterCount()*sizeof(float),16);<br />
		for(int i =pStruct->Offset;i<pStruct->End;i++)<br />
			{<br />
				for(int j = abs(LineLength%m),l=0;j<m*3,l<m;j+=3,l++)<br />
				{<br />
						double distance;<br />
						CGNTNeuron* pNeuron;<br />
						double Norm = 0;<br />
						for(int k = 0;k<pStruct->pDlg->m_poDataset->GetRasterCount();k++)<br />
						{<br />
							pInputs[k] = pStruct->pDlg->m_pImageMatrix[k][i][m-l-1];<br />
							Norm+=pInputs[k];<br />
						}<br />
						Norm = sqrt(Norm);<br />
						for(int k = 0;k<pStruct->pDlg->m_poDataset->GetRasterCount();k++)<br />
							pInputs[k]/=Norm;<br />
						EnterCriticalSection(&pStruct->pDlg->m_CriticalSection);<br />
						unsigned int value = pStruct->pDlg->m_pGNTNet->Propagate(pInputs,distance,&pNeuron);		<br />
						LeaveCriticalSection(&pStruct->pDlg->m_CriticalSection);<br />
						<br />
						*(Bitmap-LineLength-j-1) = GetRValue(value);//eto krasnii<br />
						*(Bitmap-LineLength-j-2) = GetGValue(value);//eto zelenii<br />
						*(Bitmap-LineLength-j-3) = GetBValue(value);//eto sinii<br />
				}<br />
				Bitmap+=LineLength;<br />
			}<br />
		_aligned_free(pInputs);<br />
	}<br />
	else<br />
	{<br />
		__declspec(align(16)) float* pInputs =(float*) _aligned_malloc(pStruct->pDlg->m_floatingWindowSize*pStruct->pDlg->m_floatingWindowSize*pStruct->pDlg->m_poDataset->GetRasterCount()*sizeof(float),16);<br />
		for(int i =pStruct->Offset;i<pStruct->End;i++)<br />
			{<br />
				if(i<pStruct->pDlg->m_poDataset->GetRasterYSize()-pStruct->pDlg->m_floatingWindowSize)<br />
				for(int j = abs(LineLength%m),l=0;j<m*3,l<m;j+=3,l++)<br />
				{<br />
					if(l<pStruct->pDlg->m_poDataset->GetRasterXSize()-pStruct->pDlg->m_floatingWindowSize)<br />
					{<br />
							double distance;<br />
							CGNTNeuron* pNeuron;<br />
							int ll = 0;<br />
							double Norm = 0;<br />
							for(int k = 0;k<pStruct->pDlg->m_poDataset->GetRasterCount();k++)<br />
								for(int ii = i;ii<i+pStruct->pDlg->m_floatingWindowSize;ii++)<br />
									for(int jj = l;jj<l+pStruct->pDlg->m_floatingWindowSize;jj++)<br />
									{<br />
										pInputs[ll++] = pStruct->pDlg->m_pImageMatrix[k][ii][m-jj-1];<br />
										Norm+=pStruct->pDlg->m_pImageMatrix[k][ii][m-jj-1]*pStruct->pDlg->m_pImageMatrix[k][ii][m-jj-1];<br />
									}<br />
							Norm = sqrt(Norm);<br />
							for(int k = 0;k<pStruct->pDlg->m_poDataset->GetRasterCount()*pStruct->pDlg->m_floatingWindowSize*pStruct->pDlg->m_floatingWindowSize;k++)<br />
								pInputs[k]/=Norm;<br />
							EnterCriticalSection(&pStruct->pDlg->m_CriticalSection);<br />
							unsigned int Value  = pStruct->pDlg->m_pGNTNet->Propagate(pInputs,distance,&pNeuron);		<br />
							LeaveCriticalSection(&pStruct->pDlg->m_CriticalSection);<br />
							*(Bitmap-LineLength-j-1) = GetRValue(Value);//eto krasnii<br />
							*(Bitmap-LineLength-j-2) = GetGValue(Value);//eto zelenii<br />
							*(Bitmap-LineLength-j-3) = GetBValue(Value);//eto sinii<br />
<br />
					}<br />
				}<br />
				Bitmap+=LineLength;<br />
			}<br />
		_aligned_free(pInputs);<br />
	}<br />
	return 0;<br />
}<br />
<br />

QuestionRe: Memory Leak Pin
Mark Salsbery12-Apr-07 7:50
Mark Salsbery12-Apr-07 7:50 
AnswerRe: Memory Leak Pin
Rassul Yunussov12-Apr-07 22:43
Rassul Yunussov12-Apr-07 22:43 
GeneralRe: Memory Leak Pin
Mark Salsbery13-Apr-07 7:23
Mark Salsbery13-Apr-07 7:23 
GeneralRe: Memory Leak Pin
Rassul Yunussov15-Apr-07 18:33
Rassul Yunussov15-Apr-07 18:33 
QuestionKEYEVENTF_UNICODE macro Pin
Syamlal S Nair11-Apr-07 23:20
Syamlal S Nair11-Apr-07 23:20 
AnswerRe: KEYEVENTF_UNICODE macro Pin
Gospodin Baron12-Apr-07 3:19
Gospodin Baron12-Apr-07 3:19 
GeneralRe: KEYEVENTF_UNICODE macro Pin
Syamlal S Nair16-Apr-07 22:47
Syamlal S Nair16-Apr-07 22:47 
Questionprograming with port USB Pin
maheno11-Apr-07 23:12
maheno11-Apr-07 23:12 
AnswerRe: programing with port USB Pin
Rajesh R Subramanian12-Apr-07 1:51
professionalRajesh R Subramanian12-Apr-07 1:51 
Questionloading the whole text file into an array Pin
cyn811-Apr-07 22:44
cyn811-Apr-07 22:44 
AnswerRe: loading the whole text file into an array Pin
toxcct11-Apr-07 23:04
toxcct11-Apr-07 23:04 
GeneralRe: loading the whole text file into an array Pin
cyn811-Apr-07 23:15
cyn811-Apr-07 23:15 
GeneralRe: loading the whole text file into an array Pin
toxcct11-Apr-07 23:19
toxcct11-Apr-07 23:19 
GeneralRe: loading the whole text file into an array Pin
cyn811-Apr-07 23:35
cyn811-Apr-07 23:35 
AnswerRe: loading the whole text file into an array Pin
Cedric Moonen11-Apr-07 23:10
Cedric Moonen11-Apr-07 23:10 
GeneralRe: loading the whole text file into an array Pin
cyn811-Apr-07 23:19
cyn811-Apr-07 23:19 
AnswerRe: loading the whole text file into an array Pin
Paresh Chitte11-Apr-07 23:10
Paresh Chitte11-Apr-07 23:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.