C++ Program that will fill whole memory

C++Server Side ProgrammingProgramming

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

using namespace std;
main() {
   while(true) {
      int *var = new int; //allocate memory dynamically


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.
Published on 14-Mar-2019 11:34:02