Skip to main content

Memory Virtualization



Address Spaces

    
       The range of virtual addresses that the operating system assigns to a user or separately system assigns to a user or separately running program is called an address space.

Ex: A device, A file, A server or a networked Computer.

Memory API 

 
The API achieves this by estimating the amount of memory resources that are in use.

  Eg. Malloc/ Free, calloc/realloc , brk/sbrk , mmap/mumap.


malloc()

Allocate a memory region on the heap.

      Argument
  • size_t  size : size of the memory block(in bytes).
  • size_t is an unsigned integer type.
       Return
  • Success: a void type pointer to the memory block allocated by malloc.
  • Fail : a null pointer.

sizeof()          

 Routines and macros are utilized for size in malloc instead typing a number directly.

free()

    Argument
  •    At pointer to a memory  block allocated with malloc.
       Return
  •   none.

Memory leak

  • A  program keeps allocating memory without freeing it.
  • A program runs out of memory and eventually is killed by OS.

Dangling pointer

Freeing memory while it is being used. 
  • A program accesses to memory with an invalid pointer.

malloc()

Allocate memory and zeroes it before returning.

realloc()

Change the size of memory block.

brk/sbrk

break: The location of the end of the heap in address space.
  • brk is called to expand the program's break.
  • sbrk is similar to brk.

Popular posts from this blog

Operating System

What is an operating system? An operating system (OS) is the program that, after being initially loaded into the computer by a boot program, manages all of the other application programs in a computer. The application programs make use of the operating system by making requests for services through a defined application program interface ( API ). In addition, users can interact directly with the operating system through a user interface, such as a command-line interface (CLI) or a graphical UI (GUI). Why use an operating system? An operating system brings powerful benefits to computer software and software development. Without an operating system, every application would need to include its own UI, as well as the comprehensive code needed to handle all low-level functionality of the underlying computer, such as disk storage, network interfaces and so on. Considering the vast array of underlying hardware available, this would vastly bloat the size of every application and make software