Similar Threads
1. CPaintDC Memory Leak
Hi,
I'm battling to find the cause of a memory leak in one of my evc++
dlls.
The dll creates a window, and draws to it in response to a WM_PAINT
message (as usual).
The trouble is that I've removed all the code from the OnPaint method
except the following:
void CMapWnd::OnPaint()
{
CPaintDC dc(this); // device context for painting
}
which still causes the leak.
Removing the CPaintDC line removes the leak.
Any thoughts on what could be going wrong here? I'm at my wits end.
Thanks,
Dave.
2. How to detect memory leak and detect who causes a memory leak - Windows CE
3. Memory leak even after deleting memory pointers from vector
Hi,
I am working on c++ in a linux system ( Fedora core 4 ),
kernel version - 2.6.11-1.1369_FC4
gcc version - 4.0.0 20050519 ( Red Hat 4.0.0-8 )
In my code i am creating a vector to store pointers of type structure
"SAMPLE_TABLE_STRUCT" ( size of this structure is 36 bytes ). I create
an instance of structure "SAMPLE_TABLE_STRUCT" using operator "new"
and push back into the vector,this is done inside a for loop for
204800 times. After i come out of for loop i observe the memory
consumed by the process using the command "pmap -d pid". The memory
consumption increases by approximately 8 MB. After this i delete all
the contents of vector using "delete" operator. Now if i observe the
memory consumed by the process ( using "pmap -d pid" command ) it
shows no reduction in the memory even after deallocating the memory in
the code.
It shows memory reduction after deleting vector contents if i store
the "char *" elements into the vector instead of "SAMPLE_TABLE_STRUCT
*" elements.
Am not able to figure it out why even after deleting the vector ( of
type "SAMPLE_TABLE_STRUCT *" )contents the memory reduction is not
seen...?
Can anyone please help me out here...?
Here is the piece of code where am facing the problem -
[CODE]
#define ALTERNATE
#define MAX_STRING_VEC_SIZE 134
#define MAX_STRUCT_VEC_SIZE 1024*200//134
#define MAX_MEM_SIZE 1024*50
/*vector of char * type*/
void Function()
{
std::vector< char * > v_pData;
#ifdef ALTERNATE
v_pData.resize( MAX_STRING_VEC_SIZE, NULL );
#endif //ALTERNATE
bool bFlag = true;
while( bFlag );
//Allocate Memory
for( int nInd = 0 ; nInd < MAX_STRING_VEC_SIZE; nInd++ )
{
char * pData = new char [MAX_MEM_SIZE];
memset( pData, 0, MAX_MEM_SIZE );
#ifdef ALTERNATE
v_pData[nInd] = pData;
#else //ALTERNATE
v_pData.push_back( pData );
#endif //#endif //ALTERNATE
}
bFlag = true;
while( bFlag );
//Release all the Memory
for( int nInd = 0 ; nInd < MAX_STRING_VEC_SIZE; nInd++ )
{
delete [] v_pData[nInd];
}
v_pData.clear();
}
/*vector of SAMPLE_TABLE_STRUCT * type*/
void Function1()
{
std::vector< SAMPLE_TABLE_STRUCT * > v_pData;
#ifdef ALTERNATE
v_pData.resize( MAX_STRUCT_VEC_SIZE, NULL );
#endif //ALTERNATE
//Allocate Memory
for( int nInd = 0 ; nInd < MAX_STRUCT_VEC_SIZE; nInd++ )
{
SAMPLE_TABLE_STRUCT * pData = new SAMPLE_TABLE_STRUCT;
#ifdef ALTERNATE
v_pData[nInd] = pData;
#else //ALTERNATE
v_pData.push_back( pData );
#endif //#endif //ALTERNATE
}
//Release all the Memory
for( int nInd = 0 ; nInd < MAX_STRUCT_VEC_SIZE; nInd++ )
{
delete v_pData[nInd];
v_pData[nInd] = NULL;
}
v_pData.clear();
}
[/CODE]
4. Memory leak indiaction in .NET app with C++ interop dll's
5. Memory Leak in C++ Excel RTD (same as in VCRTDServer)
My C++ RTD server is leaking memory just like the sample VCRTDServer
(provided with MSDN).
I have tried all kinds of work arounds, but cannot seem to fix the
leak -- it seems like it might be in Excel.
It appears to be related to the RefeshData() function.
Please comment if you have seen this behavior, and/or if you have a
work around.
Thanks!
Robert
6. Memory leak hosting ATL ActiveX control in C# App
7. Memory Leak in C# Windows Service
I created a windows service that performs a MSSQL2000 database analysis in a
separate threads with a specified interval. And when running this service
uses a lot of system memeory and it does release it after finishing it's
jobs and starting to "sleep". I use there Microsoft.AplicationBlocks.Data
libary to access database and I suppose the service caches the data since it
performs all the next parcings at a moment unlike at the first time for 20
minutes. Actually the service is working fine except memory leak, I have put
null to every object, and made sure that Microsoft.AplicationBlocks.Data
libary closes db connections.
Does anybody know how can I make my service to release memory when it is
finished it's job and how can I manage the ADO.NET caching?
Thanks
--
- Vlad
8. System.String memory leaks C# application