Code Like A Girl

Welcome to Code Like A Girl, a space that celebrates redefining society's perceptions of women in…

Follow publication

Member-only story

Complete Guide to Memory Management in C++ (No More Leaks!)

Nidhi Gahlawat
Code Like A Girl
Published in
6 min read5 days ago

Image by Author

1. Code segment

2. Global & Static Variables is the (Data Segment)

3. Stack

4. Heap

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Published in Code Like A Girl

Welcome to Code Like A Girl, a space that celebrates redefining society's perceptions of women in technology. Share your story with us!

Written by Nidhi Gahlawat

Software Engineer | I write about machine learning, AI, iOS dev, programming languages and everything in between | Coffee keeps me alive!

Responses (6)

Write a response

This is a super clear and concise guide to memory management in C++! Understanding the different memory regions is crucial for writing efficient and leak-free code. The breakdown makes it easy to follow—great job! Looking forward to more insights on best practices for managing heap memory.

5

And vector instead of dynamically allocated arrays

5

Why not just reassign pointer p like &p=10 ? It will be at the same place of the initial memory.

2