   Tracking Down Memory Leaks
  I''ve been writing a mud server myself, from scratch for a little while now and recently I noticed a problem. When the server starts up, I checked what amount of ram it was consuming.Next, I connect to it via telnet and the amount of ram jumps up 10k or so, which was expected. However, whenever the client disconnects it doesn''t give back any ram.The ram useage goes up about 4k every 4th to 5th connect. I''m not sure why this is. After some time, the server crashes with an ASSERT error.I''ve never dealt with memory leaks in the past, so I am not entirely sure how to look for the cause of one. I''ve spent several hours on this, to no avail. There is just no reason that I can see why it shouldn''t be freeing the ram.If you need to see specific pieces of my code, I will post anything you need.Thank-you for taking the time to read this,Michael Bartman 
  I forgot to mention, I am using Visual C++ .NET, Windows 2000, and Winsock2.2 ;  I have found out about the memory leak detection of visual studio with CRT and whatnot. I think I can track it down now, thanks anyway! ;  you can use this. It's really usefullhttp://www.FluidStudios.com/publications.html [Triple Buffer V2.0][TBEngine].... [edited by - ifoobar on August 2, 2003 8:18:17 AM];  Flipcode has a tutorial over there ( Right here ) that is exactly about finding memory leaks. It looks pretty handy, though I haven''t gotten around to playing with it yet.Hope this helps Joshvertexnormal AT email DOT comCheck out Golem at:My cheapass website;  Thanks to both of you.I fixed the problem this morning, and it was a rather simple fix.I have a method to parse an incoming buffer to remove all leading and trailing spaces, and inside of it I created a new char * that was the size of the strlen of the incoming buffer, but I never deleted it. It was a rather stupid mistake, but all is working now.I must say though, that writing a mud with the object oriented paradigm is a lot harder than with regular C. ;  er, you seem to be writing regular Cedit: and why are you making things harder for yourself?   [edited by - C-Junkie on August 2, 2003 9:49:00 PM];  A solution to all your problems.  #include <stdlib.h>#include <crtdbg.h>struct MemLeakTest{MemLeakTest() {}~MemLeakTest() {OutputDebugString("Beginning dump of memory LEAKS:\n");_CrtDumpMemoryLeaks(); OutputDebugString("Any and all memory LEAKS dumped.\n");}};There is the downside that this object must be the last object destructed in your program, which assuming it is not allocated, it will be the first created. So create a global instance of an MemLeakTest as your first global object, and when your program finishes all memory leaks will be displayed.;  Thanks haro, I have something similar set up already now though.C-Junkie:Well, I started with the intent of making it object oriented and every thing coasted along quite well until recently. Now I am running into organization problems, damnit ;  #include <crtdbg.h>#define new new(_NORMAL_BLOCK,__FILE__, __LINE__)im not sure why ms hides this so well in their documentation.i dont think they want people to write good code...