File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Garbage Collection

 
vigneswar rao
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi friends,
I have a samll doubt..
Does garbage collection guarantee that a program will not run out of memory or not ?
if run i want saple code, give me brief explaination.


thank you,
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24204
34
Chrome Eclipse IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, it doesn't guarantee that, as you can always write a program that uses more memory than is available; for example, the one line

int[][] matrix = new int[1000000][1000000];

will exhaust the memory of any 32-bit JVM.

What garbage collection does do is free you from the need to deliberately delete memory you're no longer using, as you have to do in languages like C and C++.
 
vigneswar rao
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks to

Ernest Friedman-Hill
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic