• Post Reply Bookmark Topic Watch Topic
  • New Topic

local variable and performance issue of server  RSS feed

 
Deba PratimBhuyan
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Should we restrict ourselves to define as less number of local variables of primitive and String types as possible? What is the impact of memory if we define large number of local variables? What is the load of these variables in Web servers in terms of space and time complexity, if we define them in servlets etc? Should we nullify them after use?
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Variable scope will not affect time complexity if you access them anyway. As for memory, the killers are usually when a leak happens or one of these examples

1. DOM parses huge XML
2. Entire files are read instead of streaming them with buffers
3. Byte [] buffers are saved and their references are held indefinitely
etc etc

Do you have a specific memory leak / performance problem ? And by the way, defining member variables in a servlet is a bad idea.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!