Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8875283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:56:20+00:00 2026-06-14T18:56:20+00:00

In modern-day operating systems, memory is available as an abstracted resource. A process is

  • 0

In modern-day operating systems, memory is available as an abstracted resource. A process is exposed to a virtual address space (which is independent from address space of all other processes) and a whole mechanism exists for mapping any virtual address to some actual physical address.
My doubt is:

  • If each process has its own address space, then it should be free to access any address in the same. So apart from permission restricted sections like that of .data, .bss, .text etc, one should be free to change value at any address. But this usually gives segmentation fault, why?

  • For acquiring the dynamic memory, we need to do a malloc. If the whole virtual space is made available to a process, then why can’t it directly access it?

  • Different runs of a program results in different addresses for variables (both on stack and heap). Why is it so, when the environments for each run is same? Does it not affect the amount of addressable memory available for usage? (Does it have something to do with address space randomization?)

  • Some links on memory allocation (e.g. in heap).

The data available at different places is very confusing, as they talk about old and modern times, often not distinguishing between them. It would be helpful if someone could clarify the doubts while keeping modern systems in mind, say Linux.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T18:56:21+00:00Added an answer on June 14, 2026 at 6:56 pm

    Technically, the operating system is able to allocate any memory page on access, but there are important reasons why it shouldn’t or can’t:

    different memory regions serve different purposes.

    • code. It can be read and executed, but shouldn’t be written to.
    • literals (strings, const arrays). This memory is read-only and should be.
    • the heap. It can be read and written, but not executed.
    • the thread stack. There is no reason for two threads to access each other’s stack, so the OS might as well forbid that. Moreover, the tread stack can be de-allocated when the tread ends.
    • memory-mapped files. Any changes to this region should affect a specific file. If the file is open for reading, the same memory page may be shared between processes because it’s read-only.
    • the kernel space. Normally the application should not (or can not) access that region – only kernel code can. It’s basically a scratch space for the kernel and it’s shared between processes. The network buffer may reside there, so that it’s always available for writes, no matter when the packet arrives.
    • …

    The OS might assume that all unrecognised memory access is an attempt to allocate more heap space, but:

    • if an application touches the kernel memory from user code, it must be killed. On 32-bit Windows, all memory above 1<<31 (top bit set) or above 3<<30 (top two bits set) is kernel memory. You should not assume any unallocated memory region is in the user space.
    • if an application thinks about using a memory region but doesn’t tell the OS, the OS may allocate something else to that memory (OS: sure, your file is at 0x12341234; App: but I wanted to store my data there). You could tell the OS by touching the end of your array (which is unreliable anyways), but it’s easier to just call an OS function. It’s just a good idea that the function call is “give me 10MB of heap”, not “give me 10MB of heap starting at 0x12345678“
    • If the application allocates memory by using it then it typically does not de-allocate at all. This can be problematic as the OS still has to hold the unused pages (but the Java Virtual Machine does not de-allocate either, so hey).

    Different runs of a program results in different addresses for variables

    This is called memory layout randomisation and is used, alongside of proper permissions (stack space is not executable), to make buffer overflow attacks much more difficult. You can still kill the app, but not execute arbitrary code.

    Some links on memory allocation (e.g. in heap).

    Do you mean, what algorithm the allocator uses? The easiest algorithm is to always allocate at the soonest available position and link from each memory block to the next and store the flag if it’s a free block or used block. More advanced algorithms always allocate blocks at the size of a power of two or a multiple of some fixed size to prevent memory fragmentation (lots of small free blocks) or link the blocks in a different structures to find a free block of sufficient size faster.

    An even simpler approach is to never de-allocate and just point to the first (and only) free block and holds its size. If the remaining space is too small, throw it away and ask the OS for a new one.

    There’s nothing magical about memory allocators. All they do is to:

    • ask the OS for a large region and
    • partition it to smaller chunks
    • without
      • wasting too much space or
      • taking too long.

    Anyways, the Wikipedia article about memory allocation is http://en.wikipedia.org/wiki/Memory_management .

    One interesting algorithm is called “(binary) buddy blocks”. It holds several pools of a power-of-two size and splits them recursively into smaller regions. Each region is then either fully allocated, fully free or split in two regions (buddies) that are not both fully free. If it’s split, then one byte suffices to hold the size of the largest free block within this block.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Linux or other modern OS, each process's memory is protected, so that a
In modern processors it is possible to load a register from memory and then
In the modern file systems there are files and directories. In a directory, there
What is the correct way to invoke stored procedures using modern day (circa 2012)
I tried to upload files via FTP but ran into problems. Are modern day
One of the more powerful features of modern day browsers is the ability for
I'm new to modern Java compilers and Virtual Machines, so I'm curious, what technical
I am using a Modern theme which separates all information into tabs. I want
Are there any existing modern-day programming languages that explicitly have dependency injection as a
Modern browsers save passwords. Which criteria affect this decision? Background: I have a registration

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.