|
-
August 29th, 2012, 06:28 AM
#1
Server App memory freed when disconnect the remote desktop session
I have a server application running in Windows 2003 server; I think the application has a memory leak because the memory usage increases unusually; I have checked the code (Visual c++ code) with parasoft software and I haven't found any possible memory leaks.
I used some aplications like Leakdiag to find memory leaks but I can't see the memory with it the memory usage I see in task manager and perfmon.
I usually monitor the server using remote desktop connection, when I disconnect the remote desktop session, the memory for the process is freed !. I don't know what may be happening.
Any ideas?
p.d. sorry for my bad English
-
August 29th, 2012, 12:17 PM
#2
Re: Server App memory freed when disconnect the remote desktop session
 Originally Posted by mklon22
I have a server application running in Windows 2003 server; I think the application has a memory leak because the memory usage increases unusually;
That doesn't mean you have a memory leak. That could mean that you're using the heap improperly or inefficiently. You can use the heap improperly/inefficiently and not leak any memory.
Code:
char *ptr[10000];
for (int i = 0; i < 10000; ++i )
{
// some code doing something
//...
ptr[i] = new char [10000];
// some more code
}
for (int i = 0; i < 10000; ++i )
{
delete [] ptr;
}
Assume that the first for loop is the major part of your app. Inside that loop is a lot of complex code, functions being called, etc., but the main point is that for some condition, you allocate memory. Then when you're finished, the next loop frees the memory. So where is the leak? Yes, you have a lot of dynamic memory allocation occurring during the running of the loop, and maybe this is not the best way to use memory, but it is no leak.
Regards,
Paul McKenzie
-
August 29th, 2012, 12:39 PM
#3
Re: Server App memory freed when disconnect the remote desktop session
Yes, I suspected something like that, I have monitored several days the application in order to localize the thread that consumes the memory but I haven't localize it yet.
But, if in somewhere in my code there is memory that is been allocated, why that memory is freed when I connect and disconnect a remote desktop session?.
Do you know any free application to monitor the working set used by the threads of a process? I have seen some programs that shows the CPU usage of all threads of an specific process but I haven't seen any that shows the memory usage.
Thanks.
-
August 30th, 2012, 02:32 PM
#4
Re: Server App memory freed when disconnect the remote desktop session
Yes I suspected that; I need to find which part of my code is being requesting a big amount of memory. My aplication is multithread and is too large, I was thinking to isolate the problem monitoring the memory usage of each thread but I don't know how... is there any application that does that? is there any c++ function to obtain the memory usage of a thread by thread id?
-
August 31st, 2012, 12:13 PM
#5
Re: Server App memory freed when disconnect the remote desktop session
 Originally Posted by mklon22
I have a server application running in Windows 2003 server; I think the application has a memory leak because the memory usage increases unusually; I have checked the code (Visual c++ code) with parasoft software and I haven't found any possible memory leaks.
I used some aplications like Leakdiag to find memory leaks but I can't see the memory with it the memory usage I see in task manager and perfmon.
Is the program exiting due to lack of memory? Or, are you making an assumption based on the memory usage reported by the task manager? If it's the latter, you cannot use task manager to find out precisely how much memory your app is using. The Windows memory manager will "hold" memory that you free in your application, in case your app requests more memory later. A lot of people see this when they are using the task manager to monitor memory; and find that if they minimize their app, then restore it, the memory reported in the task manager goes down. This doesn't mean that their app suddenly freed memory, the Windows memory manager just returned all the (already) free memory to the system.
Viggy
-
August 31st, 2012, 12:22 PM
#6
Re: Server App memory freed when disconnect the remote desktop session
Is this a C++.net or C++/CLI app? Not that it has to be...also does this app use Sockets?
ahoodin
To keep the plot moving, that's why.

-
August 31st, 2012, 01:16 PM
#7
Re: Server App memory freed when disconnect the remote desktop session
One month ago my colleages restarted the computer because the application was malfunctioning, I saw memory exceptions in the application log , since that I have been monitoring the memory of the process through Windows task manager and performance monitor... and I see working set going down when I disconnect the remote desktop session but the virtual memory doesn't go down...
Last edited by mklon22; August 31st, 2012 at 01:23 PM.
-
August 31st, 2012, 01:25 PM
#8
Re: Server App memory freed when disconnect the remote desktop session
Is a MFC C++ application, and yes the application uses sockets... It is a NMS application.
-
August 31st, 2012, 02:44 PM
#9
Re: Server App memory freed when disconnect the remote desktop session
 Originally Posted by mklon22
One month ago my colleages restarted the computer because the application was malfunctioning, I saw memory exceptions in the application log
Did you discover why the exceptions were occurring? Unless you do that first, you're only assuming that the issue is with allocating memory (or you're assuming that allocating memory is the only problem).
Regards,
Paul McKenzie
-
August 31st, 2012, 02:46 PM
#10
Re: Server App memory freed when disconnect the remote desktop session
 Originally Posted by mklon22
Is a MFC C++ application, and yes the application uses sockets... It is a NMS application.
Is it a multithreaded app? If so, then you need to make sure that it isn't improper usage of threads and/or a synchronization issue that is causing the problem with the exceptions that are occurring.
Regards,
Paul McKenzie
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|