# Memory error at 1000mb when trying to save an int variable

**URL:** <https://discourse.processing.org/t/memory-error-at-1000mb-when-trying-to-save-an-int-variable/10666>\
**Category:** Coding Questions\
**Created:** [April 26, 2019, 2:29pm UTC](https://discourse.processing.org/t/memory-error-at-1000mb-when-trying-to-save-an-int-variable/10666 "2019-04-26T14:29:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![LHACKS](https://avatars.discourse-cdn.com/v4/letter/l/e480ec/32.png) [@LHACKS](https://discourse.processing.org/u/LHACKS)\
**Post date:** [April 26, 2019, 2:29pm UTC](https://discourse.processing.org/t/memory-error-at-1000mb-when-trying-to-save-an-int-variable/10666/1 "2019-04-26T14:29:29Z")

</div>

So I was trying save the high score for my game and it says memory error even if I changed it to 1000Mb = 1 Gb. I’m only going to put the code for the saving process here. The high score variable has been on 40 and on 12 while I had tried to get it to save but the game freezes and it says memory error. But anyway here’s the code:

int highscore;  
String[] Save;  
String save;

void draw () {  
if(highscore \< points) {  
highscore = points;  
// the made the ‘save’ to -0.00793 times ‘highscore’ so that if someone file I named “LicenseID.txt” so that //they would not suspect it to be a save-file.  
save = str(highscore \* -0.00793);  
// I used 'Save = split(save," "); ’ because only 'Save = save; ’ would not work.  
Save = split(save, " ");  
saveStrings(“LicenseID.txt”, Save);  
}  
}

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [April 27, 2019, 11:23am UTC](https://discourse.processing.org/t/memory-error-at-1000mb-when-trying-to-save-an-int-variable/10666/2 "2019-04-27T11:23:23Z")

</div>

please post code in the

```auto
</> code tag

```

* * *

and post only running code,  
so test it after you reduced your code to a MVCE ( example snippet )

* * *

for the error pls post a copy or a picture

* * *

i play here ( win7 / 64bit / processing 3.5.3 )  
with this and it works,

```auto
int highscore = 9, points = 10;
String[] lines;
String save;
String outfile = "data/LicenseID.txt";

void setup() {
  size( 200,200 );  
}

void draw () {
  if (highscore < points) {
    highscore = points; // also disables multiple saving
    save = str(highscore * -0.00793); // the made the ‘save’ to -0.00793 times ‘highscore’ so that if someone file I named “LicenseID.txt” so that //they would not suspect it to be a save-file.
    lines = split(save, " "); // I used 'Save = split(save," "); ’ because only 'Save = save; ’ would not work.
    saveStrings(outfile, lines);
    println(" file save "+outfile);
  }
}

```

as your program not available i can only guess  
that your

```auto
if(highscore < points) {
highscore = points;

```

does not work and you try to write to file 60 times per second  
( and soon need a new disk drive )

usually, you have a concept for storing to file like

- keyboard action ‘s’
- program end

but not inside draw ( and every frame… )
