Sunday, February 2, 2014

STACK AND HEAP

I felt that these two terms are used a lot while discussing linux so a quick look at these two topics would be good.

The stacks and heaps are the part of virtual address space that consists of code;data;heap(growing upwards) and stack portion(growing downwards).( from bottom to top).

STACK:

  • This is the memory area used by our thread of execution.
  • When a function is called the local variables and return addresses are stored here.
  • The space becomes available when the function  exits.
  • The user doesn't need to take care of the memory allocation and deallocation( happens automatically).

HEAP:

  • It is the memory set aside for dynamic allocation.
  • Generally, an application is given a separate heap memory and it allocates the memory from the given heap on need basis.
  • WE can allocate and free heap anytime.
  • User must take care of deallocation of memory when he doesn't need it.
  • To get heap memory we use malloc and calloc if we are in user space and if we are in kernel space we use kmalloc, vmalloc.
  • We must free the memory allocated by using free, kfree and vfree respectively.


6 comments:

  1. Pretty! This was a really wonderful article. Many thanks for providing this info.



    Review my page :: real racing 3 cheats iphone

    ReplyDelete
  2. Hello this is somewhat of off topic but I was wanting to know if blogs use WYSIWYG editors or if
    you have to manually code with HTML. I'm
    starting a blog oon but have no coding know-how so I wanted
    to get advice from someone with experience. Anyy help wold be
    greatly appreciated!

    Feel free to surf to my web blog - xbox live code generator no surveys

    ReplyDelete
  3. Can I simply sayy what a relief to uncover a person that genuinely knows what they're talking about on the internet.
    You actuually realize hoow to bring an issue to light and make iit important.
    A lot more people need to check this out and understand this side of the story.
    I was surprised that you aren't more popular since you definitely possess the gift.


    my page - best online education degrees

    ReplyDelete
  4. Thanks for sharing the valuable information. it’s really helpful
    MEAN Stack Online Training

    ReplyDelete