AggrorJorn Posted June 27, 2013 Share Posted June 27, 2013 After a few hours of programming my computer becomes extremely slow. When looking in the task manager I can see my memory usage almost reaching its maximum (8GB!). I have no experience on how to detect memory leaks. Are there any special ways inside visual studio or C++ that allow you to pickup on memory leaks? thanks in advance. Quote Link to comment Share on other sites More sharing options...
xtreampb Posted June 28, 2013 Share Posted June 28, 2013 ensure that all pointers that are being created and assigned are you have a var for so that when you are done you can delete them. so like Class *mClass=new Class(); will need to have this when you are finished with it: delete mClass; OS X instruments tool set has memory usage profiling. it is called something along the lines of malloc debug or something along those lines. you can attach your app to the malloc process right in the xCode editor Quote bool Life() { while(death=false) { if(death==true) return death; } } I have found the secret to infinite life Did I help you out? Like my post! Link to comment Share on other sites More sharing options...
Furbolg Posted June 28, 2013 Share Posted June 28, 2013 Hi aggror (we spoken last night about it so its just a remembering) It's hard to tell where the problem comes from, here are some simple tips: - Every new requires an delete (as xtreampb has written) - Every new [] requires an delete[] Texture* arrayoftextures = new Texture[20]; delete[] arrayoftextures; // instead of delete - Use c++ constructors and destructors - Use the stack (CConsole myconsole instead of CConsole* myconsole = new CConsole when possible) - Avoid static/singletons when possible (same as global variables) There are plenty ways to detect a leak, to be honest i haven't done it for some time. As i remember you can use some CRT functions or overwrite the new/delete operators to create an allocation list. Quote Link to comment Share on other sites More sharing options...
Rick Posted June 29, 2013 Share Posted June 29, 2013 Remember to use ->Release() on LE related entities instead of delete. Quote Link to comment Share on other sites More sharing options...
Josh Posted June 29, 2013 Share Posted June 29, 2013 The application should clear any memory you leave when it ends. You might have some process running that is leaking? Have you looked at the processes in task manager to see what is consuming the memory? Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
AggrorJorn Posted June 29, 2013 Author Share Posted June 29, 2013 It only says Non-active system processes are taking up 95 CPU power. Quote Link to comment Share on other sites More sharing options...
Josh Posted June 29, 2013 Share Posted June 29, 2013 That's normal. There should be a tab for mem usage. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
panz3r Posted June 29, 2013 Share Posted June 29, 2013 This is exactly one of the reason for developing on Linux, rock solid OS where your chance that your app is causing problems are very small and very easy to spot . About windows I am not sure what task manager shows about memory, sometime i know for sure that an app allocates tons of memory but it simply does not show in task manager. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.