Hi Carlos,

You just declare a string variable outside the loop. It is not 
LCD.drawString that is the problem, but any use of a string literal:

String miRobot = "miRobot";
while (!Button.ESCAPE.isPressed()) {
  LCD.clear();
  LCD.drawString(miRobot, 0,0);
  LCD.drawInt( (int)(Runtime.getRuntime().freeMemory()),0,1);
  LCD.refresh();
}

Lawrie

----- Original Message ----- 
From: "Carlos Agüero" <[EMAIL PROTECTED]>
To: "leJOS Discussion List" <[email protected]>
Sent: Monday, October 22, 2007 3:31 PM
Subject: [Lejos-discussion] drawString method and memory


> Hi everybody,
>
> as you know, every time we do a call to drawString() mehod, a new String
> is created and we loose some bytes of memory.
>
> Is there any way or trick to avoid this loss of memory in case of we
> need to use several calls to drawString().
>
> Imagine a simple loop:
>
> while (!Button.ESCAPE.isPressed()) {
> LCD.clear();
> LCD.drawString("miRobot", 0,0);
> LCD.drawInt( (int)(Runtime.getRuntime().freeMemory()),0,1);
> LCD.refresh();
> }
>
> Is there any way to execute this kind of code without loosing all the
> memory?
>
> Thanks,
> Carlos
>
> -- 
> Carlos E. Agüero Durán  |  Grupo de Sistemas y Comunicacines (GSyC)
> http://gsyc.es/~caguero |  Universidad Rey Juan Carlos
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems?  Stop.
> Now Search log events and configuration files using AJAX and a browser.
> Download your FREE copy of Splunk now >> http://get.splunk.com/
> _______________________________________________
> Lejos-discussion mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/lejos-discussion
>


--------------------------------------------------------------------------------


No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.488 / Virus Database: 269.15.5/1084 - Release Date: 21/10/2007 
15:09


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Lejos-discussion mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/lejos-discussion

Reply via email to