Thread: Increasing working memory in win XP

  1. #1
    Registered User
    Join Date
    Dec 2005

    Increasing working memory in win XP


    I'm using the following code:

     for (k=0;k<MAX_ROW;k++)
    		geneas[k] = (char*)malloc(MAX_OF_ALL_STR);
    For my test data i had max_row = 15 but for original data i have 4000 rows!
    the C code is breaking in the malloc itself!
    Any suggestions?


  2. #2
    Registered User
    Join Date
    Feb 2006
    Great India
    Yes it's obvious that the code will break if it will not get sufficient memory for malloc().

    What you can do here is add a statement like this ?

         printf("\n Not sufficient memory");
    Now you will now where the HELL is happening ?

    Last edited by realnapster; 04-24-2006 at 03:52 AM.

  3. #3
    Just kidding.... fnoyan's Avatar
    Join Date
    Jun 2003
    Still in the egg
    You have up to 4Gb(3 userspace+1 kernel space) of memory for your application! The code below works fine on my Linux machine
    #include <stdio.h>
    #include <stdlib.h>
    #define MAX_ROW 4000
    #define MAX_OF_ALL_STR 4096
    int main()
            int k;
            char *geneas[MAX_ROW];
            for (k=0; k<MAX_ROW; k++)
                    geneas[k]=(char *)malloc(MAX_OF_ALL_STR);
                    if (geneas[k]==NULL)
                            fprintf(stderr,"malloc failed!\n");
            return 0;
    I think there may be some other problem other than allocating memory!

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    Like their compiler is some ancient fossil called TurboC perhaps, and the amount of memory they have is limited to 640K, despite the GB of memory which XP has to play with.

    Of course, without actually saying what MAX_OF_ALL_STR is, it's hard to comment.
    Perhaps it's a wasteful 1MB for each row of data.

    > geneas[k] = (char*)malloc(MAX_OF_ALL_STR);
    Read the FAQ on casting malloc - like why it's bad.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User
    Join Date
    Dec 2005
    Thanks guys- I've switched stuffs to my linux m/c and it works fine...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. To find the memory leaks without using any tools
    By asadullah in forum C Programming
    Replies: 2
    Last Post: 05-12-2008, 07:54 AM
  2. Lemmings on Win XP
    By swgh in forum A Brief History of
    Replies: 8
    Last Post: 05-07-2008, 06:11 AM
  3. Memory usage and memory leaks
    By vsanandan in forum C Programming
    Replies: 1
    Last Post: 05-03-2008, 05:45 AM
  4. Assignment Operator, Memory and Scope
    By SevenThunders in forum C++ Programming
    Replies: 47
    Last Post: 03-31-2008, 06:22 AM
  5. Working with the Registry Win 2000
    By ReggerX in forum Windows Programming
    Replies: 18
    Last Post: 08-19-2002, 06:53 AM