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
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: 40052
    
  28
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 ?