Please give me some suggestions about malloc

  • Thread starter Thread starter nenyan
  • Start date Start date
  • Tags Tags
    Suggestions
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
1 reply · 2K views
nenyan
Messages
67
Reaction score
0
Code:
#include <stdio.h>
#include <stdlib.h>
#define N 250000000

int main()
{
    int i; 
    double *x;

    if(!(x = malloc(N * sizeof(double)) ))
            printf("memory error \n");

free(x);
}
When N is larger than 2.5*10^8, it appears memory error. I have 8GB memory. The system is Windows7. How to solve this problem. I hope N=5*10^8 at least.
 
Physics news on Phys.org