Visual studio 2008 application using C++ under windows XP.
Any useful advices beyond the “always delete new objects” advice?
Edit: Actually I am looking for some programming advices.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Depends what you mean by “consumes too much memory”.
A) By design i.e. it requires to load or generate large data structures that you expect to cause problems.
In this case is it i) too much phyical memory i.e. it becomes slow because the hard drive starts swapping pages in and out or ii) too much address space i.e. it fails to allocate because it can’t find a hole in the memory?
For ii) consider using 64bit builds, consider using shared memory to store large data structures, beware of fragmentation – allocate large buffers early, break up large data structures into smaller ones
B) It surprises you by using loads of memory.
Find your leaks or bugs – various profilers available or visual studio built in debug alloc hooks. Do you have any broken arithmetic for calculating buffer sizes(especially accidental int wrap around)?
Use smart pointers to manage deletion.