Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Is this Memory Lekage?

 
vishwas bhatt
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi folks,

Image img;

img = Image.createImage("/a.png");
img = Image.createImage("/b.png");
img = Image.createImage("/c.png");
img = Image.createImage("/d.png");

is this memory lekage in j2me or java.Will it create memory fregmentation on heap.
Or i have to make first img = null and then asign new Image
 
Michael Yuan
author
Ranch Hand
Posts: 1427
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, it is not. When the img variable is assigned to the second Image instance, the first Image instance is no longer linked in the object graph and ready for garbage collection.
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!