{"id":65824,"date":"2021-07-15T04:10:07","date_gmt":"2021-07-15T08:10:07","guid":{"rendered":"http:\/\/bangla.salearningschool.com\/recent-posts\/scjp-garbage-collection-java-short-notes-scjp\/"},"modified":"2022-05-10T20:04:10","modified_gmt":"2022-05-11T00:04:10","slug":"scjp-garbage-collection-java-short-notes-scjp","status":"publish","type":"post","link":"http:\/\/bangla.sitestree.com\/?p=65824","title":{"rendered":"SCJP: Garbage Collection #Java Short Notes #SCJP"},"content":{"rendered":"<p><b>Garbage Collection<\/b><\/p>\n<ul>\n<li> Java itself does memory management. You do not need to allocate memory at the time of object creation; also you do not need to free memory explicitly <\/li>\n<li> Object is created either on the heap or on a stack <\/li>\n<li> Memory heap: Objects created with new keyword are placed in heaps. This memory remains allocated throughout the life cycle of the object. When the object is no more referred, the memory becomes eligible for garbage collection  <\/li>\n<li> Stack:  During method calls, objects are created for method arguments and method variables. These objects are created on stack. Such objects are eligible for garbage-collection when they go out of scope. <\/li>\n<li> Garbage Collection is a low-priority thread in java <\/li>\n<li> Garbage Collection cannot be forced explicitly. JVM may do garbage collection if it is running short of memory. <\/li>\n<li> The call System.gc() does NOT force the garbage collection but only suggests that the JVM may make an effort to do garbage collection.  <\/li>\n<li> Garbage Collection is hardwired in Java runtime system. Java runtime system keeps the track of memory allocated. Therefore, it is able to determine if memory is still usable by any live thread. If not, then garbage collection thread will eventually release the memory back to the heap.    <\/li>\n<li> Garbage Collection usually adopts an algorithm, which gives a fair balance between responsiveness (how quickly garbage-collection thread yields?) and speed of memory recovery (important for memory-intensive operations). Responsiveness is especially important in real time systems.    <\/li>\n<li> An object is eligible for garbage collection when no object refers to it.    <\/li>\n<li> An object also becomes eligible when its reference is set to null. (Actually all references to the object should be null for it to be eligible.)    <\/li>\n<li> The objects referred by method variables or local variables are eligible for garbage collection when the method or their container block exits<\/li>\n<\/ul>\n<p> From: http:\/\/sitestree.com\/?p=4863<br \/> Categories:Java Short Notes, SCJP<br \/>Tags:<br \/> Post Data:2009-03-10 13:59:45<\/p>\n<p>\t\tShop Online: <a href='https:\/\/www.ShopForSoul.com\/' target='new' rel=\"noopener\">https:\/\/www.ShopForSoul.com\/<\/a><br \/>\n\t\t(Big Data, Cloud, Security, Machine Learning): Courses: <a href='http:\/\/Training.SitesTree.com' target='new' rel=\"noopener\"> http:\/\/Training.SitesTree.com<\/a><br \/>\n\t\tIn Bengali: <a href='http:\/\/Bangla.SaLearningSchool.com' target='new' rel=\"noopener\">http:\/\/Bangla.SaLearningSchool.com<\/a><br \/>\n\t\t<a href='http:\/\/SitesTree.com' target='new' rel=\"noopener\">http:\/\/SitesTree.com<\/a><br \/>\n\t\t8112223 Canada Inc.\/JustEtc: <a href='http:\/\/JustEtc.net' target='new' rel=\"noopener\">http:\/\/JustEtc.net (Software\/Web\/Mobile\/Big-Data\/Machine Learning) <\/a><br \/>\n\t\tShop Online: <a href='https:\/\/www.ShopForSoul.com'> https:\/\/www.ShopForSoul.com\/<\/a><br \/>\n\t\tMedium: <a href='https:\/\/medium.com\/@SayedAhmedCanada' target='new' rel=\"noopener\"> https:\/\/medium.com\/@SayedAhmedCanada <\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Garbage Collection Java itself does memory management. You do not need to allocate memory at the time of object creation; also you do not need to free memory explicitly Object is created either on the heap or on a stack Memory heap: Objects created with new keyword are placed in heaps. This memory remains allocated &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"http:\/\/bangla.sitestree.com\/?p=65824\">Continue reading<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1917,1954],"tags":[],"class_list":["post-65824","post","type-post","status-publish","format-standard","hentry","category-fromsitestree-com","category-scjp-ocjp","item-wrap"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":65854,"url":"http:\/\/bangla.sitestree.com\/?p=65854","url_meta":{"origin":65824,"position":0},"title":"SCJP: More Rules #Java Short Notes #SCJP","author":"Sayed","date":"July 16, 2021","format":false,"excerpt":"java -classpath gFolder\/Game.jar civilization.java: In such command, -classpath will override (replace) CLASSPATH environment variable. java -classpath gFolder\/Game.jar civilization.java: if both gFolder and current directory contain Game.jar then the jar file under gFolder will be used. If you want java compiler to recognize your jar file, either you have to mention\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":22130,"url":"http:\/\/bangla.sitestree.com\/?p=22130","url_meta":{"origin":65824,"position":1},"title":"SCJP: Topics and Resources : will be continued #SCJP","author":"Sayed","date":"March 10, 2021","format":false,"excerpt":"SCJP topics and related resources are provided. I have skimed through the resources at least one time.Garbage Collection Test area:Given a code example, recognize the point at which an object becomes eligible for garbage collection, determine what is and is not guaranteed by the garbage collection system, and recognize the\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":65858,"url":"http:\/\/bangla.sitestree.com\/?p=65858","url_meta":{"origin":65824,"position":2},"title":"SCJP Essential Knowledge #Java Short Notes #SCJP","author":"Sayed","date":"July 16, 2021","format":false,"excerpt":"int x=5; String y=\"3\"; System.out.print(x + 1 + y); Output: 63 When there is no live reference to an object, the object becomes eligible for garbage collection. The concrete interface method implementation must be public. When a class implements Comparator, it must implement a compare method. When a class implements\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":65844,"url":"http:\/\/bangla.sitestree.com\/?p=65844","url_meta":{"origin":65824,"position":3},"title":"Java : SCJP: Important Resources #Java Short Notes #SCJP","author":"Sayed","date":"July 16, 2021","format":false,"excerpt":"How to use generics to avoid runtime errors. More Generics Class casting in Java: How to avoid runtime exception - ClassCastException: overloading, overriding, variable and method hiding Java HotSpot virtual machine What Java Technology can do? Offers from Java Technology Java:Common Problems (and Their Solutions) Benefits of OOP: Modularity, Information-hiding,\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":22132,"url":"http:\/\/bangla.sitestree.com\/?p=22132","url_meta":{"origin":65824,"position":4},"title":"SCJP: Sun Certified Java Programmer: All that you need to know #SCJP","author":"Sayed","date":"March 10, 2021","format":false,"excerpt":"Introduction to Sun Certified Java Programmer Certification CourseJava : SCJP: Important ResourcesJAVA: Some links: useful for exams like scjp\/scjaSCJP Essential KnowledgeSCJP Practice ExamsSCJP Training: Lesson 1: Develop code that declares classes (including abstract and all forms of nested classes), interfaces, and enums, and includes the appropriate use of package and\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":74773,"url":"http:\/\/bangla.sitestree.com\/?p=74773","url_meta":{"origin":65824,"position":5},"title":"Are you interested in becoming a Java Developer and OCJP","author":"Sayed","date":"May 31, 2022","format":false,"excerpt":"Are you interested in becoming a Java Developer and OCJP? OCJP: Oracle Certified Java Programmer? Are you interested in a Java based career track? Short Notes on: OCJP: Oracle Certified Java Programmer Certification. Written long back in the SCJP time. These are for quick review purposes, not really to learn\u2026","rel":"","context":"In &quot;\u09ac\u09cd\u09b2\u0997 \u0964 Blog&quot;","block_context":{"text":"\u09ac\u09cd\u09b2\u0997 \u0964 Blog","link":"http:\/\/bangla.sitestree.com\/?cat=182"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/65824","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=65824"}],"version-history":[{"count":2,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/65824\/revisions"}],"predecessor-version":[{"id":74750,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/65824\/revisions\/74750"}],"wp:attachment":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=65824"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=65824"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=65824"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}