Out of memory error
Erio Magnoni <magnonie-ur28x6/[email protected]>
| Newsgroups | gmane.comp.hardware.microcontrollers.tini |
|---|---|
| Message-ID | <[email protected]> |
Hi everyone!
I have some problems writing on a file..after some time a
java.lang.OutOfMemoryError is thrown such as follows:
java.lang.OutOfMemoryError
in java.io.OutputStreamWriter.<init><@JPC=110025>
in java.io.FileWriter.<init><@JPC=160008>
in Misura.Scrivifile<@JPC=a005c>
in java.lang.system.???
As I can see the problem is in the method Scrivifile in my class called Misura.
I have to write a .txt file with two float type values and have to refresh it
periodically.
The problem happens when I start a webserver (the same of the examples in
ftp.dalsemi.com) together with the process Misura that performs some
measurements and writes them on a file; after a while my TINI displays the
error and exits from the two processes.
What can I do?
Thanks for support!
Best regards,
Erio Magnoni.
Here is the source code:
public class Misura
{
public static int controllo = 0;
.....
Scrivifile(1, vis1); // vis1 and vis2 are two float type values
Scrivifile(7, vis2);
.....
static void Scrivifile(int i, float sample) throws IOException
{
if(controllo != 0 && controllo < 2)
{
try {
BufferedWriter out = new BufferedWriter(new FileWriter
("data.txt", true));
PrintWriter printout = new PrintWriter(out);
printout.println(i + ", " + sample);
printout.close();
controllo++;
} catch (IOException e) {}
} else {
try {
boolean exists = (new File("data.txt")).exists();
if (exists) {
// Il file o la directory esistono
boolean success = (new File("data.txt")).delete
();
if (!success) {
// Cancellazione non effettuata
System.out.println("Errore,
cancellazione non effettuata!");
}
BufferedWriter out = new BufferedWriter(new FileWriter
("data.txt"));
PrintWriter printout = new PrintWriter(out);
printout.println("Valori rilevati:");
printout.println(i + ", " + sample);
printout.close();
controllo = 0;
controllo++;
} else {
// Il file o la directory non esistono
BufferedWriter out = new BufferedWriter(new FileWriter
("data.txt"));
PrintWriter printout = new PrintWriter(out);
printout.println("Valori rilevati:");
printout.println(i + ", " + sample);
printout.close();
controllo = 0;
controllo++;
}
} catch (IOException e) {}
}
}
.....
}
-------------------------------------------------
This mail sent through IMP: https://mail.die.supsi.ch
_______________________________________________
TINI mailing list
TINI-6tN4nzCoH/[email protected]
To UNSUBSCRIBE, edit your profile, or see list archives:
http://lists.dalsemi.com/mailman/listinfo/tini