[Solved] Is there any code snippet demonstrate the harm of memory leak or fogeting free memory malloced [closed]


Okay I will explain the problem.

  • Computers has limited memory ( modern personal one has about 8 Gigabytes).
    Operating systems and apps need the memory so their code can be loaded into it and executed by the CPU.
  • Modern systems split the memory into equally sized chunks called pages, the actual page size differs from system to another
  • So, the computer has limited size of pages (memory chunks).. What happens if the running processes require more pages than the limit ??

    • Simply the operating system takes a few pages from the memory and save it to the hard-disk, this known as swapping
    • Later the process may need a page that was swapped-out, so the operating system will swap it in, as hard-disks are much slower, it impacts the performance badly

    • If there is a lot of swapping operations, this is called thrashing.

So the bottom line, if there is a process who leaks memory. the system will keep thrashing and processes will wait in a long queue for the hard-disk device.

I also encourage you to learn about computer architecture and operating system to get deep insights.

2

solved Is there any code snippet demonstrate the harm of memory leak or fogeting free memory malloced [closed]