Question

Write a program using C/C++ to demonstrate the memory leak problem. Execute the program until it cannot proceed anymore. You may have to allocate big chunks of memory iteratively to reach to this poin...

Write a program using C/C++ to demonstrate the memory leak problem.
Execute the program until it cannot proceed anymore. You may have to allocate big chunks of memory iteratively to reach to this point quickly. This is even more so if you are running the program on a 64-bit operating system. Based on your observation and your understanding of the principles of a paging memory management system, answer the following questions:
A. How much memory has the program used when reaching the point where it cannot proceed anymore? What is the physical (32-bit or 64-bit) and logical address space of the computer you run this application on? What is the size of the physical memory (RAM) of the computer you run this application on?
B. What type of memory, virtual or physical, is exhausted when there is a memory leak problem with a process?
C. When a process that has a memory leak problem cannot proceed anymore, does it prevent any other program from starting/running due to lack of memory? Does it slow down the whole system?
D. On a platform which has built-in garbage collection mechanism, e.g., .NET and JVM, to a large extent, the memory leak problem can be avoided. Why?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Program:

//header files
#include <iostream>
using namespace std;

// function with memory leak
void memoryleak()
{
    int* ptr = new int(15);
    // memory of the pointer is not deallocated
    //it will call a memory leakage
    return;
}

// driver code
int main()
{
    //calling function
    memoryleak();

    return 0;
}


a. The system is based on 64 bit architecture and has 4 GB of RAM

b. In memory leakage, physical memory is exhausted

c. When a memory leakage occur then the process cannot proceed further and it consume the available memory, slowing down the other process

d. Memory leakage problem can be avoided in system where inbuilt garbage collectors are used as they will free the memory if it is not required anymore

Add a comment
Know the answer?
Add Answer to:
Write a program using C/C++ to demonstrate the memory leak problem. Execute the program until it cannot proceed anymore. You may have to allocate big chunks of memory iteratively to reach to this poin...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT