About Memory Management When mentioning C++

When someone mention the memory management the c++ is capable of doing, how can i see this thing? is this done in theory like guessing? i took a logical design intro course and it covered the systems of numbers and boolean algebra and combinational logic,will this help? so say in Visual Studio , is there some kind of a tool to visualize the memory,i hope im not being ridiculous here ?


thank you.

Answers


C++ has a variety of memory areas:

  • space used for global and static variables, which is pre-allocated by the compiler
  • "stack" memory that's used for preserving caller context during function calls, passing some function arguments (others may fit in CPU registers), and local variables
  • "heap" memory that's allocated using new or new[](C++'s preferred approach) or malloc (a lower-level function inherited from C), and released with delete, delete[] or free respectively.

The heap is important in that it supports run-time requests for arbitrary amounts of memory, and the usage persists until delete or free is explicitly used, rather than being tied to the lifetime of particular function calls as per stack memory.

I'm not aware of any useful tools for visualising and categorising the overall memory usage of a running C++ program, less still for relating that back to which pointers in the source code currently have how much memory associated with them. As a very general guideline, it's encouraged to write code in such a way that pointers are only introduced when the program is ready to point them at something, and they go out of scope when they will no longer pointer at something. When that's impractical, it can be useful to set them to NULL (0), so that if you're monitoring the executing program in a debugger you can tell the pointer isn't meant to point to legitimate data at that point.


Need Your Help

Installing 64 bit pygame on to python 2.7, 'python version 2.7 required'

python python-2.7 install pygame

I recently downloaded the unofficial 64 bit version of pygame from this site and tried installing it. While going through the process, it tells me 'Python version 2.7 required, which was not found ...

jquery get radio value on change

javascript jquery html

i am using: http://blogs.digitss.com/javascript/jquery-javascript/jquery-fancy-custom-radio-and-checkbox/

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.