Paul Horn

Greenhorn
+ Follow
since Nov 03, 2004
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Paul Horn

Thanks for tidying up my post! :-)

And thanks for the pointer to the other discussion. That's what I thought I had learned during my research - until I was poking around with the subject of this discussion, Enumerator vs. Iterator. We recently had a programmer change a handful of interfaces from one to the other, and he claimed "better performance" for his rationale. I was using this discussion & the sample code to vet his theory.

However, when I ran the code example for timing differences (w/sun jdk 1.4.1_05 on NT), I noticed that it consistently gobbled up several megabytes of free memory during every execution; the "free memory" would drop steadily with each iteration, and end up significantly lower at the end.

Seeing that the loop is merely iterating and assigning, not explicitly allocating any new variables, why is the program continually allocating more and more memory? I thought maybe the reason was the local variable in/out of the loop, but that appears to make no difference (the memory consumed was exactly identical either way).

Any ideas? Am I blind and missing something obvious?

Thx -
- Paul
19 years ago
Am I missing something?

I've been looking for some information on the cost of creating variables inside large loops, instead of creating the variable outside the loop & then simply assigning it.

In other words, does it matter to speed or memory or both to do this:



rather than re-delcare the variable inside the loop:



I tried messing with Dark Vachor's code post above, moving Enumeration, int and Vector objects outside the main loop. So now the main loop looks like this:


Now that the loop is not doing anything but iterating, why does it still take up megabytes of memory? What's it allocating?

- Paul
[ November 04, 2004: Message edited by: Ilja Preuss ]
19 years ago