
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C++ Program That Will Fill Whole Memory
In this article we will see how to fill the whole memory by writing a simple C++ program. Here the logic is very simple. We shall create new integer variables by using the dynamic memory allocation. If we create some variables again and again, it will fill the entire primary memory.
In C++ to dynamically allocate a memory space we can use the new keyword.
The basic syntax of the new operator is like below.
pointer_var = new data_type
To deallocate the memory space, we can use the delete keyword. The syntax is
delete pointer_var
Note After running this program it may slow down the performance of the system. The total system may not work properly due to the lack of memory space.
Example Code
#include<iostream> using namespace std; main() { while(true) { int *var = new int; //allocate memory dynamically } }
Output
Here we cannot get any specific output to display. We can check the memory status in the task manager to get the idea about the output.
Advertisements