memory allocation by OS memory manager

memory allocation by OS memory manager

Post by bhaveshpat.. » Sun, 18 Jul 1999 04:00:00



Dear everyone,
I have some questions regarding OS memory manger.

1. Will OS memory manger alloate memory from the virtual space
   or physical space or both? Will it have to worry about physical
   memory availablity, setting page table etc..?

2  how brk() is implemented?

with regards,
bhavesh

Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.

 
 
 

1. Infinite memory?!? Memory allocation bug with gcc?

Hi.

        Is there a memory allocation bug in gcc?  I'm running Linux
1.2.13, gcc 2.7 and libc 5.0.9.  If I compile and run the small
program below, malloc (or new, if I use g++) manages to allocate much
more memory that is available (including virtual memory).  For
example, here I have 40MB of physical memory and 32MB of swap space,
but malloc manages to allocate 1143 blocks of 1MB before returning
NULL!!!  Where is this memory coming from?

------------%< Beginning of code %<----------
#include <stdlib.h>

#define NB 120
#define BLOCK 1024*1024

char *iv[NB];

main()
{
  int i,j;

  for (i=0; i<NB; i++) {
    printf("%d  ", i);
    iv[i] = (char *)malloc(BLOCK);
    if (iv[i]==NULL) {
      printf("out of memory \n");
      exit(-1);
    }
  }
  for (;;) {
    for (i=0; i<NB; i++)
      for (j=0; j<BLOCK; j++)
        iv[i][j] = iv[i][j] + 1;
  }
------------%< end of code %<-----------

        On the code above, if I set NB to anything below 1143, the
program runs without segmentation faults or other errors.  Linux
starts to swap heavily, and becomes almost unusable, but doesn't die.

        However, if I request only one large block, malloc correctly
returns NULL if the block is bigger than the available memory.

        Is this a known bug?  Must I upgrade immediatly?

        Many thanks in advance.

Celso.

2. How to stop 2.6 from rotating through ip addresses?

3. Memory allocation and de-allocation

4. Striped But Lobsided Disk Utilization.....

5. How to by-pass OS virtual memory manager?

6. Howto exit smit

7. maximum memory allocation

8. Can't mount root fs

9. Still problems with memory allocations

10. Allocation of memory failed

11. memory alloc failuer : __alloc_pages: 1-order allocation failed.

12. memory allocation problems(brk fails with EGAIN, ENOMEM etc.,

13. Newbie question on memory allocation