Memory management...

Date: Wed Aug 02 2000 - 14:09:50 EST

Howdi friends,
    I'm a bit new to linux, and perhaps don't belong on this mail list, but I've run across something that I just don't see as right. Here's some code I put together that has no problem bringing kernel 2.2.5-15 to it's knees even when run without any special priveleges. what's the situation?

Here's the code:

// Tested on kernel 2.2.5-15, this code crashes the system by allocating
// all system memory and writing data to it.

#include <stdlib.h>
#include <stdio.h>

void main(void)
   unsigned long int mem = (1024 * 1024) + 1;
   int i = 0;
   char * data[10];
   unsigned long int loop;

   printf("Finding max memory allocatable...");
      data[i] = malloc(mem * 1024);
      if(data[i] != NULL)
         printf("Allocated %dKB of memory.\n", mem);
         printf("Filling with 0x00...");
         for(loop = 0; loop < mem * K; loop++) *(data[i] + loop) = 0x00;
   while(mem != 0);
   printf("All memory allocated.\n");
   printf("Press <ENTER> to free memory...\n");
   while(i != 0)
   printf("Memory freed. Goodbye.\n");

Thanks for your time,

Christopher George

Get your free email from AltaVista at

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
Please read the FAQ at

This archive was generated by hypermail 2b29 : Mon Aug 07 2000 - 21:00:09 EST