require this C malloc program analysis

From: kernel.lover (
Date: 03/10/05

Date: 10 Mar 2005 09:52:01 -0800

        I download this code from worx site with some of my
modification appear below. i want to ask why this program fails to run
after megs_obtained with 660 value?
        Also as it concern with avail memory allocation, how more that
256MB memory be given to this program?
I am using Fedora Core 1 with 256 physical RAM and 80GB HDD.
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>

#define ONE_K (1024)

int main() {
    char *some_memory;
    int size_to_allocate = ONE_K;
    int megs_obtained = 0;
    int ks_obtained = 0;

    while (megs_obtained<724) {
        for (ks_obtained = 0; ks_obtained < 1024; ks_obtained++) {
            some_memory = (char *)malloc(size_to_allocate);
            if (some_memory == NULL) exit(EXIT_FAILURE);
            sprintf(some_memory, "Hello World");
        printf("Now allocated %d Megabytes\n", megs_obtained);