Re: memory management



Thomas Kellerer wrote:
As far as I can tell, this will create huge strings with the complete
result set, as they are declared outside the loop (actually twice the
result set because one for the out_Record and one for the in_record).

Ingo Menger wrote:

Actually 4-fold, since at the end he does:

log += out_record + in_record;
//out.print(st);
out.print(log);

Just changing this will save 50% memory:

Actually even more than that, because all the intermediate strings are there from each iteration. Given n iterations, aren't there O(n^2) Strings generated?

--
Lew
.



Relevant Pages

  • Re: C# coding guidelines: use "this." or not when referring to member fields/properties within the
    ... Alphabetic for strings isn't quite so ... One example of where people go wrong is when they want to optimise loop ... implementation so that each iteration takes 10% less time will only ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Efficient looping
    ... > statement in the loop then run each loop and see which one goes faster: ... 22 microseconds per iteration ... strings, but I saw an improvement for longer strings, iirc. ... changed it to the foreach way. ...
    (comp.lang.tcl)
  • Re: GC performance with lists
    ... One thing to do is to calc i+1 etc before the j loop instead of on ... every iteration. ... to store the result If I have to calculate something more than twice. ...
    (comp.lang.python)
  • Yow! LOOP macros are LOOPY!
    ... By relying entirely on procedure calls to express iteration, ... to but cleaner than C's FOR loop. ... other macros going around at the time other than MacLisp's ... (bind (vi (vector-ref v i))) ...
    (comp.lang.scheme)
  • Re: Polling, Interrupts, DMA, Synchronous, Asynchronous I/O Definitions
    ... the terminology is less useful than it might be. ... though a "message loop" could arguably be claimed to be ... considering in a particular iteration but what is true for _ALL_ ... watching the "polling" version eating up every single CPU cycle ...
    (alt.lang.asm)