Eradicating Memory Leaks in JavaScript

Ayush Gupta
Updated on 17-Sep-2019 08:15:58

182 Views

The main cause for leaks in garbage collected languages are unwanted references. To understand memory leaks, let us see how the memory freeing(garbage collection) works.Mark-and-sweep algorithm −This algorithm reduces the definition of "an object is no longer needed" to "an object is unreachable". This algorithm assumes the knowledge of a set of objects called roots. In JavaScript, the root is the global object. Periodically, the GC starts from these roots, find all objects that are referenced from these roots, recursively. Starting from the roots, the GC will thus find all reachable objects and collect all non-reachable objects.Types of memory leaks1. ... Read More

HTML a Href Attribute

AmitDiwan
Updated on 17-Sep-2019 08:14:27

350 Views

The href attribute is used to set the link i.e. the URL of the page.SyntaxFollowing is the syntax −Above, URL is the url you need to mention, which can be a relative link, absolute link, script, protocol, etc.ExampleLet us now see an example to implement the href attribute of the element − Live Demo Learning is Fun Learn the concepts of Java! Also try JavaScript from our website: JavaScript! OutputThis will produce the following output −ExampleLet us see another example wherein we can set the email-id of a user with a href − Live ... Read More

Avoid Circular Reference in OOP JavaScript

Ayush Gupta
Updated on 17-Sep-2019 08:05:54

491 Views

A circular reference occurs if two separate objects pass references to each other.In older browsers circular references were a cause of memory leaks. With improvements in Garbage collection algorithms, which can now handle cycles and cyclic dependencies fine, this is no longer an issue.However, from a pure design point of view, circular referencing is still a bad thing and a code smell. Circular referencing implies that the 2 objects referencing each other are tightly coupled and changes to one object may need changes in other as well.Avoiding circular referencesThere is no one way to avoid circular reference in JS. It ... Read More

Why Circular Reference is Bad in JavaScript

Ayush Gupta
Updated on 17-Sep-2019 08:02:47

1K+ Views

A circular reference occurs if two separate objects pass references to each other.In older browsers circular references were a cause of memory leaks. With improvements in Garbage collection algorithms, which can now handle cycles and cyclic dependencies fine, this is no longer an issue.However, from a pure design point of view, circular referencing is still a bad thing and a code smell. Circular referencing implies that the 2 objects referencing each other are tightly coupled and changes to one object may need changes in other as well.Avoiding circular referencesThere is no one way to avoid circular reference in JS. It ... Read More

HTML Textarea Disabled Attribute

AmitDiwan
Updated on 17-Sep-2019 07:58:58

43 Views

The disabled attribute of the element is used to disable . After disabling, you won’t be able to select the text from the .SyntaxFollowing is the syntax −ExampleLet us now see an example to implement the disabled attribute of the element − Live Demo Candidate Details Student Name: Student Id: Educational Qualification (Graduation) B.Tech BCA B.COM B.SC BBA Educational Qualification (Post-Graduation) MCA M.Tech M.COM M.SC Info: You need to also bring the certificates for the degrees mentioned above. OutputThis will produce the following output −In the above example, ... Read More

HTML Option Disabled Attribute

AmitDiwan
Updated on 16-Sep-2019 11:33:11

437 Views

The disabled attribute of the element is used to set a disabled option from a list of options. After that, the disabled option won’t be clickable.SyntaxFollowing is the syntax −ExampleLet us now see an example to implement the disabled attribute of the element − Live Demo Impurity level of Water Impurity Level 3:2 5:3 2L 5L 10L 20L OutputThis will produce the following output. Here, the option 5:3 under the optgroup Ratio −In the above example, we have option-groups and options inside it − 3:2 5:3 ... Read More

Difference Between Iterator and ListIterator in Java

Nitin Sharma
Updated on 16-Sep-2019 11:31:47

1K+ Views

Java provided these two interfaces to traverse the data one by one stored in a collection. The internal implementation of iterator and list iterator makes them differ apart but the main agenda of both the iterators is the same.The following are the important differences between Iterator and ListIterator.Sr. No.KeyIteratorListIterator1ApplicableIterator can be used to traverse any collection irrespective of the type of collection.List iterator can only be used to iterate only List collection implemented classes like arraylist, linkedlist etc.2CallingAs mentioned Iterator must be used to enumerate elements in all Collections implemented interfaces like Set, List, Queue, Deque and also in all ... Read More

HTML meter min Attribute

AmitDiwan
Updated on 16-Sep-2019 11:28:21

152 Views

The min attribute of the element is used to set the lower bound for . However, the element is used to measure data with a give range like water impurity level and it is set using the min and max attribute.SyntaxFor obvious reasons, the min value is less than the max value. The default is 0. Following is the syntax −The num above is a number in floating-point that sets the min attribute of the element.ExampleLet us now see an example to implement the min attribute of the element − Live Demo Water Levels Impurity ... Read More

HTML label for Attribute

AmitDiwan
Updated on 16-Sep-2019 11:16:41

224 Views

The for attribute of the element is used to set an element with a label.SyntaxFollowing is the syntax −Above, id is the associated element id.ExampleLet us now see an example to implement the for attribute of element − Live Demo Last Semester Results Result Student: Subject: Rank: OutputThis will produce the following output −In the above example, we have a form with some fields − Result Student: Subject: Rank: We have set the label for the field using for attribute of the element, ... Read More

Difference Between a Static Queue and a Singly Linked List in Java

Nitin Sharma
Updated on 16-Sep-2019 11:10:29

864 Views

In Java List and Queue both are introduced as an ordered list of objects, where the same object may be added more than once. The difference between both comes in the manner of adding elements. In the queue, all the elements get inserted at the rear and removed from the front while we can add an element anywhere in the list.Sr. No.KeyStatic QueueSingly Linked List1Data initialization.Static Queue works in first out(FIFO) fashion as all the elements get inserted at the REAR and removed from the FRONT of the queue.In the case of Singly Linked List, one can add elements anywhere ... Read More

Advertisements