Question: hi have a template with a form and many inputs that pass some data trough a POST request to a view, that process them and send the result to another template. in the final template, if i use the browser back button to jump to the first view, i can see again old data. i refresh the page and i insert new data, i submit again but some old data remain when i see the final view. the problem remain even if i restart the debug server. how can i prevent it? it seems that there's some data-caching that i can solve only flushing browser cache. this is the view code: <http://dpaste.com/640956/> and the first template code: <http://dpaste.com/640960/>

any idea?

tnx - luke

Answer: 
You're allocating a huge array in stack:

```
int prime[2000000]={};

```

Four bytes times two million equals eight megabytes, which is often the maximum stack size. Allocating more than that results in segmentation fault.

You should allocate the array in heap, instead:

```
int *prime;
prime = malloc(2000000 * sizeof(int));
if(!prime) {
    /* not enough memory */
}
/* ... use prime ... */
free(prime);

```
Here is my implementation.

```
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int* sieve(int n) {
  int* A = calloc(n, sizeof(int));
  for(int i = 2; i < (int) sqrt(n); i++) {
    if (!A[i]) {
      for (int j = i*i; j < n; j+=i) {
        A[j] = 1;
      }
    }
  }
  return A;
}

```

I benchmarked it for the first 1,000,000,000 numbers on an i5 Kaby Lake.

```
 time ./sieve 1000000000
./sieve 1000000000  16.21s user 1.05s system 99% cpu 17.434 total

```

I simply translated [this](https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes#Algorithm_and_variants) pseudocode from Wikipedia.