Click here to Skip to main content
15,918,967 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Very weird problem... Pin
Nish Nishant7-Feb-02 17:01
sitebuilderNish Nishant7-Feb-02 17:01 
GeneralRe: Very weird problem... Pin
Tim Smith7-Feb-02 17:01
Tim Smith7-Feb-02 17:01 
GeneralRe: Very weird problem... Pin
Nish Nishant7-Feb-02 17:25
sitebuilderNish Nishant7-Feb-02 17:25 
GeneralRe: Very weird problem... Pin
Sprudling7-Feb-02 17:30
Sprudling7-Feb-02 17:30 
GeneralRe: Very weird problem... Pin
Nish Nishant7-Feb-02 18:12
sitebuilderNish Nishant7-Feb-02 18:12 
GeneralRe: Very weird problem... (just a comment) Pin
moliate8-Feb-02 0:49
moliate8-Feb-02 0:49 
GeneralMFC/Web Services Pin
Dejan Petrovic7-Feb-02 14:27
Dejan Petrovic7-Feb-02 14:27 
QuestionHow much memory am I really using Pin
Bill Wilson7-Feb-02 12:24
Bill Wilson7-Feb-02 12:24 
I have a service that appears to eat memory at a pretty steady rate. If I bring up Task Manager, I can watch the Virtual Memory (and real memory) counter climb steadily.

In trying to solve the problem I used the CRT library to checkpoint the memory periodically. This technique has allowed me to find and fix several leaks.

Now, however, the CRT library machines are telling me there are no more leaks, while the task manager says there are still some left (real and VM still rises steadily). Following the example in MSDN, I've declared 3 _CrtMemState variables as globals (s1, s2, s3).

My app does a check point into s1 and then sets a timer.

When the timer goes off, the handler executes and then does another checkpoint into s2. The two checkpoints are compared into s3 and the result reported, as usual. The report shows differences in allocated memory between s1 and s2, as you would expect. The interesting part is that none of the allocation numbers change, while the Task manager keeps saying I'm eating memory!!

I know the checkpointing is working because the display shows a higher total allocations count each time.

Any ideas would be appreciated.

Here's the code I'm using for the checkpoints.

// global variables
_CrtMemState s1, s2, s3;


// last step of initialization

	_CrtMemCheckpoint(&s1);		
	::SetTimer(NULL, NULL, 1, OnPollTimer ); // First polling cycle is immediate

// Here's the callback code

VOID CALLBACK OnPollTimer( HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime )
{

	AFX_MANAGE_STATE(AfxGetStaticModuleState( ));

	
	_Module.m_bProcessRunning = TRUE;
	// Kill the timer
	::KillTimer(hwnd, idEvent);

	DoPollTimer();
	TRACE0(_T("OnPollTimer 1\r\n"));
_CrtMemCheckpoint(&s2);
_CrtMemDifference(&s3, &s1, &s2);
_CrtMemDumpStatistics(&s3);	

TRACE0("----------------------------------------------------------\r\n");
	
	::SetTimer(NULL, NULL, g_lPollFreqSecs * SECOND, OnPollTimer );
	_Module.m_bProcessRunning = FALSE;

}


I don't have access to the server right now, so I can't provide a sample of the output. It shows some memory allocated as normal, client and CRT. The numbers don't change from one iteration to the next.

Any ideas would be greatly appreciated.


Thanks for the help,
Bill
AnswerRe: How much memory am I really using Pin
Tim Smith7-Feb-02 13:22
Tim Smith7-Feb-02 13:22 
GeneralRe: How much memory am I really using Pin
Bill Wilson7-Feb-02 13:29
Bill Wilson7-Feb-02 13:29 
GeneralCListCtrl into ClistView !!! Pin
7-Feb-02 11:45
suss7-Feb-02 11:45 
GeneralRe: CListCtrl into ClistView !!! Pin
Michael Dunn7-Feb-02 12:09
sitebuilderMichael Dunn7-Feb-02 12:09 
GeneralRe: CListCtrl into ClistView !!! Pin
8-Feb-02 8:38
suss8-Feb-02 8:38 
GeneralPostQuitMessage in WinCE 3.0 Pin
Mel Stober7-Feb-02 10:56
Mel Stober7-Feb-02 10:56 
GeneralRe: PostQuitMessage in WinCE 3.0 Pin
Joaquín M López Muñoz7-Feb-02 11:59
Joaquín M López Muñoz7-Feb-02 11:59 
GeneralRe: PostQuitMessage in WinCE 3.0 Pin
Paul Wolfensberger18-Jun-02 10:47
Paul Wolfensberger18-Jun-02 10:47 
GeneralRe: PostQuitMessage in WinCE 3.0 Pin
Mel Stober18-Jun-02 10:51
Mel Stober18-Jun-02 10:51 
GeneralRe: PostQuitMessage in WinCE 3.0 Pin
Paul Wolfensberger19-Jun-02 2:23
Paul Wolfensberger19-Jun-02 2:23 
Generalparsing / data-mining a message received on window socket Pin
mr_k7-Feb-02 10:33
mr_k7-Feb-02 10:33 
GeneralRe: parsing / data-mining a message received on window socket Pin
Joaquín M López Muñoz7-Feb-02 12:12
Joaquín M López Muñoz7-Feb-02 12:12 
GeneralXp Icons Pin
Swinefeaster7-Feb-02 10:20
Swinefeaster7-Feb-02 10:20 
Generalquestion Pin
7-Feb-02 10:15
suss7-Feb-02 10:15 
GeneralRe: question Pin
Christian Graus7-Feb-02 10:37
protectorChristian Graus7-Feb-02 10:37 
GeneralAbout TAPI 3.0 COM problems Pin
7-Feb-02 10:18
suss7-Feb-02 10:18 
GeneralRe: About TAPI 3.0 COM problems Pin
Joaquín M López Muñoz7-Feb-02 10:24
Joaquín M López Muñoz7-Feb-02 10:24 

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.