Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Being more strict on Memory Leaks

 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am sorry , i cant think any better heading for this question .

If we don't want to our Application to allow memory leaks ,then what is the best thing to do .

For example consider in a case of JDBC application :



Please share your ideas , what will be the good approach .
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18020
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
More like:


But a better solution would be to use something like the Spring Framework that wraps that stuff automatically. Less coding, less debugging, less chance someone will forget to do proper cleanup.

Incidentally, apps I've seen that were prone to leak memory very commonly did so precisely because they didn't have proper interception and cleanup of errors. Error-based leaks are slower to accumulate than most others, but sooner or later, they will add up.

And yest, you should close connections. If they're pooled connections and you don't close them, you won't only leak memory, you'll leak connections, and thereby eventually exhaust the connection pool. Which will bring you down a lot faster than memory leaks.
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If they're pooled connections and you don't close them, you won't only leak memory, you'll leak connections


Thank you for this .
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic