Is malloc allocating memory on the virtual memory space ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,



I have been trying to understand some performance and limitations issues of a program written in C for

Hp-UX 11. I am using Malloc to allocate memory for two arrays (huge arrays). If I try to go beyond 1G

the program crashes. when I look at the stats using glance RSS and VSS look pretty much the same (RSS 1047364 and VSS 1048808) my understanding (I guess wrong) was that Malloc allocated on Virtual memory.

Is there a way in C to allocate on VM only so the process address space (1G) is not touched (or barely touched). Thanks a lot for your help



here is the code causing problems:

--------------------------------------------

typedef double *row_type;
row_type *Matrix_da_or, *matrix_l ;
int  num_trn = 656000; int maxstring 141;

void initialize_all()
{
  register int i;
  if(!(Matrix_da_or=(row_type *)malloc(num_trn * sizeof(row_type))))
    printf("error in matrix data\n");
  for(i=0;i<num_trn;i++)
    if(!(Matrix_da_or[i]=(double *)malloc((maxstring) * sizeof(double))))
      printf("error in row data %i\n",i);
    if(!(matrix_l=(row_type *)malloc(num_trn * sizeof(row_type))))
    printf("error in matrix l\n");
  for(i=0;i<num_trn;i++)
    if(!(matrix_l[i]=(double *)malloc((maxstring-2) * sizeof(double))))
    printf("error in row l %i\n",i);   /* I get the error here after gobling up 1G of memory*/
}



Regards



Csr


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux