|
|
вернуться в форумTroubles with Java I tried to receive accept using Java... Now I have only one trouble: "PrintStream System.out" saves all data which is outputted. So it uses unnecessary almost 1MB :( If somebody knows how to cope with it, please, tell me. Re: Troubles with Java I'm not sure, but mb calling "System.out.flush()" several times while outputing can help... Re: Troubles with Java Thank you :) I already tried... System.out is autoflushable so flush() doesn't change anything. Edited by author 26.08.2007 12:40 Re: Troubles with Java Hm... IMHO there is no place to store the previous output in java.lang.PrintStream. I think that plenty of temporary objects are creating in some operations (using Strings) in System.out.print(...). Of course they aren't deleting by the garbage collector during one-second thread lifetime. Try to use System.out.write(byte), it seems to be OK there. (So you have to implement some boring things...). I also had troubles with java.lang.String... Discovering O(n) performance of operator+ was at the wrong time :). Edited by author 27.08.2007 02:05 Re: Troubles with Java System.out=F; Of course, i used exactly F.write(int), it calls F.out.write(int) where F.out is OutputStream which F gets from its constructor. And how F.out is implemented, i don't know... And don't know where it can be read about :( Btw... I tried to use garbage collector with hands, it uses 1.5M itself :( >> I also had troubles with java.lang.String... Discovering O(n) performance of operator+ was at the wrong time :). Thank you for experience =) Edited by author 27.08.2007 13:05 Re: Troubles with Java Source code of all java libraries is fully avalible, there is the src.zip file in the root folder of JDK. That code isn't so complicated. In this problem... I've tried to submit code like this: public class A { public static void main(String[] args) { int[]a = new int[100000]; //to get ML, not OL, the size was different - I can't remember it for(int i = 0; i < 100000; ++i) { //also 100000 isn't true //System.out.print('1'); - case 1 //System.out.write((int)'1'); - case 2 } } } Case 1 got ML, but case 2 uses the same amount of memory like the code without any output.. Edited by author 27.08.2007 13:34 |
|
|