Welcome to pickSourcecode.com Login | Register    
pickZy.com
 Home  | search  | games  | General  | C  | C++  | Java  | Php  | Networking  | Visual Basic  | VC++  | Win32  | MFC  | JavaScript  | Jobs  | Post jobs
Manage Memory Efficiently
2009-11-21 |  RatheeshTR  | Viewed: 54  |    0

Manage Memory Efficiently:

Because C++ objects are often allocated from the heap and have limited scope, memory use in C++ programs affects performance more than in C programs.

  • In a structure, declare the largest members first.
  • In a structure, place variables near each other if they are frequently used together.
  • Ensure that objects that are no longer needed are freed or otherwise made available for reuse. One way to do this is to use an object manager. Each time you create an instance of an object, pass the pointer to that object to the object manager. The object manager maintains a list of these pointers. To access an object, you can call an object manager member function to return the information to you. The object manager can then manage memory usage and object reuse.
  • Avoid copying large, complicated objects.
  • Avoid performing a deep copy if a shallow copy is all you require. For an object that contains pointers to other objects, a shallow copy copies only the pointers and not the objects to which they point. The result is two objects that point to the same contained object. A deep copy, however, copies the pointers and the objects they point to, as well as any pointers or objects contained within that object, and so on.

Submitted By:
Prof: Software Engineer
Tech: C ,Cpp
Send Mail: ratheesh



Related topics
Manage Memory Efficiently

Related References
c - malloc, alloc, memory allocation c
c program using system v shared memory segments in linux

Web site contents © Copyright 2007, All rights reserved.
Help | Terms and Conditions | Privacy Policy | About Us