Q:

How to allocate large volume(of the order of GBs) of memory in c?

I am trying to use malloc in c language for allocating large volume of data us.When I increase the array size beyond certain value the program terminates saying "program.c" stopped working.I would like to know the correct way of assigning large volume of data(Here it is 4GB) to variables in general in c.I am using 64 bit windows on 32GB RAM .Here is the code for reference. 
   #include<stdio.h>
   #include<math.h>
   #include<conio.h>
   #include<stdlib.h>
   double** Allocate(int d1,int d2);
   double** Allocate(int d1,int d2)
   {  
      double **m;
      int i,j;
      m = (double**)malloc(sizeof(double*)*d1);  
      for(i=0;i<d1;i++)
      {
       m[i]=(double*)malloc(sizeof(double)*d2);
      }
     for(i=0;i<d1;i++)
       {
        for(j=0;j<d2;j++)
         {
           m[i][j]=0.0;
         }
       }
     return m;
   }
   main()
   {
    int i,j;
    int n=2.2e4;
    double** A= Allocate(n,n);  
    printf("Memory allocation successful");
   }

A:

The posted program works fine on a machine with 64-bit Windows and 8GB of RAM. The amount of RAM you have doesn't have anything to do with it, on a demand-paged virtual memory operating system your program allocates address space.  You don't use RAM until you start using the address space, happens when you set the array elements to 0.  You can never run out of RAM.  
The most obvious reason why you can't allocate the address space is because your program runs in 32-bit mode.  You must select the x64 platform for your project.  If you use VS then use Build > Configuration Manager > Active solution platform combobox.  Technically you could make it work in 32-mode by using the /LARGEADDRESSAWARE linker option (doubles the address space from 2GB to 4GB) but there isn't any real point in doing that.
How much address space you can allocate ultimately depends on the size of the paging file and how fast the OS can grow it.  With 32GB of installed RAM you are not close to that limit yet.

