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

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);
}
}

1 Like

please post code in the

</> 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,

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

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… )

1 Like