SlideShare a Scribd company logo
1 of 10
Download to read offline
How C++ program stored in
RAM
C/C++ PROGRAM STORED IN RAM MEMORY
The memory layout of program is organized by 4 segments
● Text segment
● Data segment
● Heap segment
● Stack segment
C PROGRAM STORED IN RAM MEMORY
Text segment
● Text segment contains executable instructions of program, it is also
called code segment.
● The text segment is sharable so that only a single copy needs to be in
memory for different executing programs, such as text editors, shells,
and so on.
● Text segment is read-only, to prevent a program from accidentally
modifying its instructions.
Data segment
Two subsections of Data segment
Initialized data
● It contains both static and global data that initialized with non-zero
values.
● This segment can be further classified into the read-only area and read-
write area.
Uninitialized data (BSS segment)
● An uninitialized data segment also called the BSS( ‘Block
Started by Symbol’ ) segment.
● Which contains all global and static variables that
initialized to zero or do not have explicit initialization in
source code.
Heap segment
● The heap segment is an area where dynamically allocated memory by
using (new).
● When we allocate memory through dynamic allocation techniques(in
other words, run-time memory allocation), program acquire space from
OS and process address space grows
(cont)
Heap segment
● We can free dynamically allocated memory space (by using free() or
delete).
● Freed memory goes back to the heap but doesn’t have to be returned
to OS (it doesn’t have to be returned at all), so unordered
malloc/free eventually, cause heap fragmentation.
● When we use dynamic allocation to acquire memory space we must
keep track of allocated memory by using its address.
Stack segment
● The stack segment is an area where local variables stored.
● When we call any function, the stack frame created and when a
function returns, the stack frame destroyed/rewind including all local
variables of that particular function.
● A stack frame contains some data like return address, arguments passed
to it, local variables, and any other information needed by the invoked
function.
Stack Segment
● A stack pointer(SP) which is a special function register of CPU keeps
track of stack by each push & pop operation onto it, by adjusted stack
pointer to next or previous address.
● The direction of the stack & heap growth completely depends on the
compiler, OS and hardware.

More Related Content

What's hot

N301 Von Neumann Architecture
N301 Von Neumann ArchitectureN301 Von Neumann Architecture
N301 Von Neumann Architectureguest3b9707
 
Register organization, stack
Register organization, stackRegister organization, stack
Register organization, stackAsif Iqbal
 
Von Neumann vs Harvard Architecture
Von Neumann vs Harvard ArchitectureVon Neumann vs Harvard Architecture
Von Neumann vs Harvard ArchitectureOLSON MATUNGA
 
Harvard vs Von Neumann Architecture
Harvard vs Von Neumann ArchitectureHarvard vs Von Neumann Architecture
Harvard vs Von Neumann ArchitectureProject Student
 
Von Neumann Architecture
Von Neumann ArchitectureVon Neumann Architecture
Von Neumann ArchitectureJawad Farooqi
 
Flow control in computer
Flow control in computerFlow control in computer
Flow control in computerrud_d_rcks
 
Software Design Practices for Large-Scale Automation
Software Design Practices for Large-Scale AutomationSoftware Design Practices for Large-Scale Automation
Software Design Practices for Large-Scale AutomationHao Xu
 
Map reduce presentation
Map reduce presentationMap reduce presentation
Map reduce presentationAhmad El Tawil
 
Understanding memory management
Understanding memory managementUnderstanding memory management
Understanding memory managementGokul Vasan
 
HARVARD & VON-NEUMANN ARCHITECTURE
HARVARD & VON-NEUMANN ARCHITECTUREHARVARD & VON-NEUMANN ARCHITECTURE
HARVARD & VON-NEUMANN ARCHITECTURESwaroopSorte
 
Page Replacement Algorithms
Page Replacement AlgorithmsPage Replacement Algorithms
Page Replacement AlgorithmsKashif Dayo
 
Von neumann Architecture | Computer Science
Von neumann Architecture | Computer ScienceVon neumann Architecture | Computer Science
Von neumann Architecture | Computer ScienceTransweb Global Inc
 
Blackfin Processor Core Architecture Part 3
Blackfin Processor Core Architecture Part 3Blackfin Processor Core Architecture Part 3
Blackfin Processor Core Architecture Part 3Premier Farnell
 
Cisc vs risc
Cisc vs riscCisc vs risc
Cisc vs riscKumar
 
Processor organization & register organization
Processor organization & register organizationProcessor organization & register organization
Processor organization & register organizationGhanshyam Patel
 
Precessor organization
Precessor organizationPrecessor organization
Precessor organizationAsif Iqbal
 

What's hot (20)

N301 Von Neumann Architecture
N301 Von Neumann ArchitectureN301 Von Neumann Architecture
N301 Von Neumann Architecture
 
Register organization, stack
Register organization, stackRegister organization, stack
Register organization, stack
 
Von Neumann vs Harvard Architecture
Von Neumann vs Harvard ArchitectureVon Neumann vs Harvard Architecture
Von Neumann vs Harvard Architecture
 
Harvard vs Von Neumann Architecture
Harvard vs Von Neumann ArchitectureHarvard vs Von Neumann Architecture
Harvard vs Von Neumann Architecture
 
Computer system architecture
Computer system architectureComputer system architecture
Computer system architecture
 
Von Neumann Architecture
Von Neumann ArchitectureVon Neumann Architecture
Von Neumann Architecture
 
Flow control in computer
Flow control in computerFlow control in computer
Flow control in computer
 
Aca2 09 new
Aca2 09 newAca2 09 new
Aca2 09 new
 
MICROPROCESSOR
MICROPROCESSORMICROPROCESSOR
MICROPROCESSOR
 
Software Design Practices for Large-Scale Automation
Software Design Practices for Large-Scale AutomationSoftware Design Practices for Large-Scale Automation
Software Design Practices for Large-Scale Automation
 
Map reduce presentation
Map reduce presentationMap reduce presentation
Map reduce presentation
 
Understanding memory management
Understanding memory managementUnderstanding memory management
Understanding memory management
 
HARVARD & VON-NEUMANN ARCHITECTURE
HARVARD & VON-NEUMANN ARCHITECTUREHARVARD & VON-NEUMANN ARCHITECTURE
HARVARD & VON-NEUMANN ARCHITECTURE
 
Page Replacement Algorithms
Page Replacement AlgorithmsPage Replacement Algorithms
Page Replacement Algorithms
 
Von neumann Architecture | Computer Science
Von neumann Architecture | Computer ScienceVon neumann Architecture | Computer Science
Von neumann Architecture | Computer Science
 
Blackfin Processor Core Architecture Part 3
Blackfin Processor Core Architecture Part 3Blackfin Processor Core Architecture Part 3
Blackfin Processor Core Architecture Part 3
 
Cisc vs risc
Cisc vs riscCisc vs risc
Cisc vs risc
 
Processor organization & register organization
Processor organization & register organizationProcessor organization & register organization
Processor organization & register organization
 
Transf from csv to xml
Transf from csv to xmlTransf from csv to xml
Transf from csv to xml
 
Precessor organization
Precessor organizationPrecessor organization
Precessor organization
 

Similar to How c++ stored in ram

C MEMORY MODEL​.pptx
C MEMORY MODEL​.pptxC MEMORY MODEL​.pptx
C MEMORY MODEL​.pptxSKUP1
 
C MEMORY MODEL​.pptx
C MEMORY MODEL​.pptxC MEMORY MODEL​.pptx
C MEMORY MODEL​.pptxLECO9
 
Sap memory management ,workload and performance analysis.pptx
Sap memory management ,workload and performance analysis.pptxSap memory management ,workload and performance analysis.pptx
Sap memory management ,workload and performance analysis.pptxsweta prakash sahoo
 
CSE2010- Module 4 V1.pptx
CSE2010- Module 4 V1.pptxCSE2010- Module 4 V1.pptx
CSE2010- Module 4 V1.pptxMadhuraK13
 
IT Revision.pptx
IT Revision.pptxIT Revision.pptx
IT Revision.pptxEzazkhan19
 
the-cpu-design-central-processing-unit-design-1
the-cpu-design-central-processing-unit-design-1the-cpu-design-central-processing-unit-design-1
the-cpu-design-central-processing-unit-design-1Basel Mansour
 
ASSEMBLY LANGUAGE.pptx
ASSEMBLY LANGUAGE.pptxASSEMBLY LANGUAGE.pptx
ASSEMBLY LANGUAGE.pptxEdFeranil
 
Loader and Its types
Loader and Its typesLoader and Its types
Loader and Its typesParth Dodiya
 
Addressing modes (detailed data path)
Addressing modes (detailed data path)Addressing modes (detailed data path)
Addressing modes (detailed data path)Mahesh Kumar Attri
 
Storage management
Storage managementStorage management
Storage managementAtul Sharma
 
Memory Allocation & Direct Memory Allocation in C & C++ Language PPT
Memory Allocation & Direct Memory Allocation in C & C++ Language PPTMemory Allocation & Direct Memory Allocation in C & C++ Language PPT
Memory Allocation & Direct Memory Allocation in C & C++ Language PPTAkhilMishra50
 
C++ Memory Management
C++ Memory ManagementC++ Memory Management
C++ Memory ManagementRahul Jamwal
 
Bab 4
Bab 4Bab 4
Bab 4n k
 
ppt on Segmentation in operationg system
ppt on Segmentation in operationg systemppt on Segmentation in operationg system
ppt on Segmentation in operationg systemsuraj sharma
 
Computer organisation and architecture jntuh 2rd year 2nd unit # central proc...
Computer organisation and architecture jntuh 2rd year 2nd unit # central proc...Computer organisation and architecture jntuh 2rd year 2nd unit # central proc...
Computer organisation and architecture jntuh 2rd year 2nd unit # central proc...preethi3173
 

Similar to How c++ stored in ram (20)

C MEMORY MODEL​.pptx
C MEMORY MODEL​.pptxC MEMORY MODEL​.pptx
C MEMORY MODEL​.pptx
 
C MEMORY MODEL​.pptx
C MEMORY MODEL​.pptxC MEMORY MODEL​.pptx
C MEMORY MODEL​.pptx
 
Segmentation
SegmentationSegmentation
Segmentation
 
Sap memory management ,workload and performance analysis.pptx
Sap memory management ,workload and performance analysis.pptxSap memory management ,workload and performance analysis.pptx
Sap memory management ,workload and performance analysis.pptx
 
Cache memory
Cache memoryCache memory
Cache memory
 
Memory Management
Memory ManagementMemory Management
Memory Management
 
CSE2010- Module 4 V1.pptx
CSE2010- Module 4 V1.pptxCSE2010- Module 4 V1.pptx
CSE2010- Module 4 V1.pptx
 
IT Revision.pptx
IT Revision.pptxIT Revision.pptx
IT Revision.pptx
 
the-cpu-design-central-processing-unit-design-1
the-cpu-design-central-processing-unit-design-1the-cpu-design-central-processing-unit-design-1
the-cpu-design-central-processing-unit-design-1
 
ASSEMBLY LANGUAGE.pptx
ASSEMBLY LANGUAGE.pptxASSEMBLY LANGUAGE.pptx
ASSEMBLY LANGUAGE.pptx
 
Loader and Its types
Loader and Its typesLoader and Its types
Loader and Its types
 
Addressing modes (detailed data path)
Addressing modes (detailed data path)Addressing modes (detailed data path)
Addressing modes (detailed data path)
 
Storage management
Storage managementStorage management
Storage management
 
Memory Allocation & Direct Memory Allocation in C & C++ Language PPT
Memory Allocation & Direct Memory Allocation in C & C++ Language PPTMemory Allocation & Direct Memory Allocation in C & C++ Language PPT
Memory Allocation & Direct Memory Allocation in C & C++ Language PPT
 
Opetating System Memory management
Opetating System Memory managementOpetating System Memory management
Opetating System Memory management
 
C++ Memory Management
C++ Memory ManagementC++ Memory Management
C++ Memory Management
 
Bab 4
Bab 4Bab 4
Bab 4
 
ppt on Segmentation in operationg system
ppt on Segmentation in operationg systemppt on Segmentation in operationg system
ppt on Segmentation in operationg system
 
Computer organisation and architecture jntuh 2rd year 2nd unit # central proc...
Computer organisation and architecture jntuh 2rd year 2nd unit # central proc...Computer organisation and architecture jntuh 2rd year 2nd unit # central proc...
Computer organisation and architecture jntuh 2rd year 2nd unit # central proc...
 
Design
DesignDesign
Design
 

More from Ashok Raj

Manipulators in c++
Manipulators in c++Manipulators in c++
Manipulators in c++Ashok Raj
 
Command line arguments
Command line argumentsCommand line arguments
Command line argumentsAshok Raj
 
High Performance Computer
High Performance ComputerHigh Performance Computer
High Performance ComputerAshok Raj
 
Super computers
Super computersSuper computers
Super computersAshok Raj
 
Pros and cons of c as a compiler language
  Pros and cons of c as a compiler language  Pros and cons of c as a compiler language
Pros and cons of c as a compiler languageAshok Raj
 
Programming language paradigms
Programming language paradigmsProgramming language paradigms
Programming language paradigmsAshok Raj
 
Printers and its types
Printers and its typesPrinters and its types
Printers and its typesAshok Raj
 
Microprocessor
MicroprocessorMicroprocessor
MicroprocessorAshok Raj
 
Mother board
Mother boardMother board
Mother boardAshok Raj
 
Embedded systems
Embedded systemsEmbedded systems
Embedded systemsAshok Raj
 
FULL stack -> MEAN stack
FULL stack -> MEAN stackFULL stack -> MEAN stack
FULL stack -> MEAN stackAshok Raj
 

More from Ashok Raj (11)

Manipulators in c++
Manipulators in c++Manipulators in c++
Manipulators in c++
 
Command line arguments
Command line argumentsCommand line arguments
Command line arguments
 
High Performance Computer
High Performance ComputerHigh Performance Computer
High Performance Computer
 
Super computers
Super computersSuper computers
Super computers
 
Pros and cons of c as a compiler language
  Pros and cons of c as a compiler language  Pros and cons of c as a compiler language
Pros and cons of c as a compiler language
 
Programming language paradigms
Programming language paradigmsProgramming language paradigms
Programming language paradigms
 
Printers and its types
Printers and its typesPrinters and its types
Printers and its types
 
Microprocessor
MicroprocessorMicroprocessor
Microprocessor
 
Mother board
Mother boardMother board
Mother board
 
Embedded systems
Embedded systemsEmbedded systems
Embedded systems
 
FULL stack -> MEAN stack
FULL stack -> MEAN stackFULL stack -> MEAN stack
FULL stack -> MEAN stack
 

Recently uploaded

Osi security architecture in network.pptx
Osi security architecture in network.pptxOsi security architecture in network.pptx
Osi security architecture in network.pptxVinzoCenzo
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shardsChristopher Curtin
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogueitservices996
 
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdfSteve Caron
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesVictoriaMetrics
 
eSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolseSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolsosttopstonverter
 
Introduction to Firebase Workshop Slides
Introduction to Firebase Workshop SlidesIntroduction to Firebase Workshop Slides
Introduction to Firebase Workshop Slidesvaideheekore1
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLionel Briand
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecturerahul_net
 
Best Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITBest Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITmanoharjgpsolutions
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...Bert Jan Schrijver
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...OnePlan Solutions
 
SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?Alexandre Beguel
 
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...kalichargn70th171
 
Understanding Plagiarism: Causes, Consequences and Prevention.pptx
Understanding Plagiarism: Causes, Consequences and Prevention.pptxUnderstanding Plagiarism: Causes, Consequences and Prevention.pptx
Understanding Plagiarism: Causes, Consequences and Prevention.pptxSasikiranMarri
 
Zer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfZer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfmaor17
 
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdfAndrey Devyatkin
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics
 
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4jGraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4jNeo4j
 
Strategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsStrategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsJean Silva
 

Recently uploaded (20)

Osi security architecture in network.pptx
Osi security architecture in network.pptxOsi security architecture in network.pptx
Osi security architecture in network.pptx
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogue
 
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 Updates
 
eSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolseSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration tools
 
Introduction to Firebase Workshop Slides
Introduction to Firebase Workshop SlidesIntroduction to Firebase Workshop Slides
Introduction to Firebase Workshop Slides
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and Repair
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecture
 
Best Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITBest Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh IT
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
 
SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?
 
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...
 
Understanding Plagiarism: Causes, Consequences and Prevention.pptx
Understanding Plagiarism: Causes, Consequences and Prevention.pptxUnderstanding Plagiarism: Causes, Consequences and Prevention.pptx
Understanding Plagiarism: Causes, Consequences and Prevention.pptx
 
Zer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfZer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdf
 
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
 
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4jGraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
 
Strategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsStrategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero results
 

How c++ stored in ram

  • 1. How C++ program stored in RAM
  • 2. C/C++ PROGRAM STORED IN RAM MEMORY The memory layout of program is organized by 4 segments ● Text segment ● Data segment ● Heap segment ● Stack segment
  • 3. C PROGRAM STORED IN RAM MEMORY
  • 4. Text segment ● Text segment contains executable instructions of program, it is also called code segment. ● The text segment is sharable so that only a single copy needs to be in memory for different executing programs, such as text editors, shells, and so on. ● Text segment is read-only, to prevent a program from accidentally modifying its instructions.
  • 5. Data segment Two subsections of Data segment Initialized data ● It contains both static and global data that initialized with non-zero values. ● This segment can be further classified into the read-only area and read- write area.
  • 6. Uninitialized data (BSS segment) ● An uninitialized data segment also called the BSS( ‘Block Started by Symbol’ ) segment. ● Which contains all global and static variables that initialized to zero or do not have explicit initialization in source code.
  • 7. Heap segment ● The heap segment is an area where dynamically allocated memory by using (new). ● When we allocate memory through dynamic allocation techniques(in other words, run-time memory allocation), program acquire space from OS and process address space grows (cont)
  • 8. Heap segment ● We can free dynamically allocated memory space (by using free() or delete). ● Freed memory goes back to the heap but doesn’t have to be returned to OS (it doesn’t have to be returned at all), so unordered malloc/free eventually, cause heap fragmentation. ● When we use dynamic allocation to acquire memory space we must keep track of allocated memory by using its address.
  • 9. Stack segment ● The stack segment is an area where local variables stored. ● When we call any function, the stack frame created and when a function returns, the stack frame destroyed/rewind including all local variables of that particular function. ● A stack frame contains some data like return address, arguments passed to it, local variables, and any other information needed by the invoked function.
  • 10. Stack Segment ● A stack pointer(SP) which is a special function register of CPU keeps track of stack by each push & pop operation onto it, by adjusted stack pointer to next or previous address. ● The direction of the stack & heap growth completely depends on the compiler, OS and hardware.