Hi Tom, Tom Denham <[EMAIL PROTECTED]> wrote: > > I've been using leJOS for a little while now, but I'm not sure I fully > understand the effects of not having a garbage collector. Is declaring a > variable inside a method bad practice?
no, this is allocated on the stack and freed automatically when the method exits. > I thought that this could be the case > because new memory would be allocated each time the method is called. Or > does the memory get released when the variable goes out of scope? Does the > same apply when declaring a variable inside a "for loop" for example? Yes and yes, mostly. More precisely, the space for these variables is reserved on the stack when the method is entered, and freed when it is exited. The lack of a garbage collector will only bite you if you create too many objects with the new operator, these are never recycled. Hope this helps Jürgen -- Jürgen Stuber <[EMAIL PROTECTED]> http://www.jstuber.net/ gnupg key fingerprint = 2767 CA3C 5680 58BA 9A91 23D9 BED6 9A7A AF9E 68B4 ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642 _______________________________________________ Lejos-discussion mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/lejos-discussion
