This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes any resource or performance (memory or cpu) issue does this code present ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "any resource or performance (memory or cpu) issue does this code present ?" Watch "any resource or performance (memory or cpu) issue does this code present ?" New topic
Author

any resource or performance (memory or cpu) issue does this code present ?

Raj Ohadi
Ranch Hand

Joined: Jun 30, 2006
Posts: 316
If I have a code like



When N is big number, the code keeps looping for N times. My question is --- when program loops for N times, does it eat lot of memory or what ? what kind resource problem it may cause when N is big ? what kind of performance problem it may cause (ignore the time that it takes toloop, that's not an issue) ?
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


when program loops for N times, does it eat lot of memory or what ?

This is the sort of question that is best answered empirically. What did you observe when you ran it?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38045
    
  22
It probably doesn't require a lot of memory; the many numbers can all fit into one int space, which is updated every iteration.
I suggest you change it to read
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: any resource or performance (memory or cpu) issue does this code present ?
 
Similar Threads
Help with simple Recursive functions
Garbage collection?
Returning the last line in a file.
Counting uppercase? Part 2!
Stock Overflow Error