Thursday, February 4, 2021

Meditation

Inhale and Exhale Time (in milliseconds):
Your browser doesn't support!

LUDO

Play LUDO on your desktop browser!

Wednesday, February 3, 2021

Biodata

 


Jayram Kumar

(+91) 9717-523-812

Jayram.bajrangi@gmail.com 



Education

Indian Institute of Technology (BHU), Varanasi

2008 – 2012

  • B. Tech. in Computer Science and Engineering (CGPA: 7.03)


Patna Science College


2007

  • Bihar School Examination Board (Percentage: 71.33%)


High School Barhiya

2005

  • Bihar School Examination Board (Percentage: 81.57%)



Family Details

  • Father: Sri Krishna Nandan Saw

  • Brothers: Kishor (Eldest), Vikash, Gopal

  • Mother: Manju Devi

  • Sister: Soni Kumari (Youngest)


Personal Information

  • Address: Near Lohiya Chawk, Barhiya – 811302, Bihar

  • Date of Birth: 10th Oct 1989

    • Height: 5’6’’

    • Complexion: Sanwla

    • Languages: English, Hindi



    Eclipse Memory Analyzer (MAT)

    The Eclipse Memory Analyzer is a Java heap analyzer that helps you find memory leaks and reduce memory consumption.

    Heap

    An untidy collection of objects placed randomly on top of each other.

    Java Heap

    Java Heap space is used by java runtime to allocate memory to Objects and JRE classes. Whenever we create an object, it's always created in the Heap space. Garbage Collection runs on the heap memory to free the memory used by objects that don't have any reference.

    Heap (data structure)

    A heap is a tree-based data structure which is an almost complete tree that satisfies the heap property: if P is a parent node of C, then the key (the value) of P is either greater than or equal to (in a max heap) or less than or equal to (in a min heap) the key of C.

    Complete Tree

    A full binary tree is a tree in which every node other than the leaves has two children. A complete binary tree is a binary tree in which every level, except possibly the last, is completely filled, and all nodes are as far left as possible.


    The heap is one implementation of an abstract data type called a priority queue. A heap is useful when it is necessary to repeatedly remove the object with the highest (or lowest) priority.


    A common implementation of a heap is the binary heap, in which the tree is a binary tree.

    The binary heap was introduced as a data structure for the heapsort sorting algorithm. Binary heaps may be represented using an array alone. The first element will contain the root. The children of the node at position n would be at positions 2n + 1 and 2n + 2 in a zero-based array.

    HeapSort

    The algorithm divides its input into a sorted and an unsorted region, and it iteratively shrinks the unsorted region by extracting the largest element and moving that to the sorted region.


    The heapsort algorithm involves preparing the list by first turning it into a max heap. The algorithm then repeatedly swaps the first value of the list with the last value, decreasing the range of values considered in the heap operation by one, and sifting the new first value into its position in the heap. This repeats until the range of considered values is one value in length.


    HeapSort is not a stable sort. Stable sort algorithms sort repeated elements in the same order that they appear in the input.

    Priority Queue

    A priority queue is an abstract data type which is like a regular queue or stack data structure, but where additionally each element has a "priority" associated with it. An element with high priority is served before an element with low priority.


    A priority queue must at least support the following operations:

    • Insert_with_priority

    • pull_highest_priority_element


    In a stack, the priority of each inserted element is monotonically increasing; thus, the last element inserted is always the first retrieved. In a queue, the priority of each inserted element is monotonically decreasing; thus, the first element inserted is always the first retrieved.

    Using a priority queue to sort

    Insert all the elements to be sorted into a priority queue, and sequentially remove them; they will come out in sorted order.

    Note: Heap Data Structure is NOT related to Java Heap in any way.

    Basics

    Java Persistence API (JPA)

    The Java Persistence API (JPA) is a Java application programming interface specification that describes the management of relational data in Java applications. The reference implementation for JPA is EclipseLink. Persistence covers three areas:

    1. The API

    2. java Persistence Query Language (JPQL): makes queries against entities stored in a relational database.

    3. object/relational metadata: A persistence entity is a lightweight Java class whose state is typically persisted to a table in a relational database. Relationships between two entities are expressed through object/relational metadata.

    Lazy loading

    Lazy loading is a design pattern commonly used in computer programming to defer initialization of an object until the point at which it is needed. The opposite of lazy loading is eager loading. The performance gains are especially significant if the initialization of the object is costly, such as in case of accessing network services. 

    Weaving

    Weaving is a technique of manipulating the byte-code of compiled Java classes. The EclipseLink JPA persistence provider uses weaving to enhance both JPA entities and Plain Old Java Object (POJO) classes for such things as lazy loading.


    Weaving can be performed either dynamically at runtime when entities are loaded, or statically at compile time. Use dynamic weaving to weave application class files one at a time, as they are loaded at run time. Use static weaving to weave all application class files at build time. 

    ClassLoaders in Java

    Class loaders are responsible for loading Java classes during runtime dynamically to the JVM. Java classes aren’t loaded into memory all at once, but when required by an application. There are three different class loaders:

    1. Application or System: Takes care of loading all the application level classes. Loads files found in the classpath environment variable. Child of Extension class loader.

    2. Extension: Loads the extensions of the standard core Java classes so that it’s available to all applications running on the platform. Loads from the $JAVA_HOME/lib/ext directory. Child of the Bootstrap class loader.

    3. Bootstrap or Primordial (displayed as null): Part of the core JVM and is written in native code. Loads core libraries located in $JAVA_HOME/jre/lib directory. Parent of all the other ClassLoader instances.

    Custom ClassLoader

    Used to load classes out of the local hard drive or a network. It acts as weaving agents. Browsers use a custom class loader to load executable content from a website.

    Daemon Thread vs User Thread in Java

    The main difference between a user thread and a daemon thread is that your Java program will not finish execution until one of the user thread is live. On the other hand, a daemon thread doesn't get that preference, JVM will exit and close the Java program even if there is a daemon thread running in the background. Any new thread spawned from a daemon thread also becomes a daemon. Once a Java program starts, one thread starts running immediately. This is usually called main thread. Main thread is a non-daemon thread. Daemon thread is mostly created by JVM e.g. for some garbage collection job.

    Java Native Interface (JNI)

    At times, it is necessary to use native (non-Java) codes (e.g., C/C++) to overcome the memory management and performance constraints in Java. Java supports native codes via the Java Native Interface (JNI).

    Monitors – The Basic Idea of Java Synchronization

    A monitor can be considered as a building which contains a special room. The special room can be occupied by only one customer(thread) at a time. The room usually contains some data and code. If a customer wants to occupy the special room, he has to enter the Hallway(Entry Set) to wait first. Every Java object and class is logically associated with a monitor.

    To implement the mutual exclusion capability of monitors, a lock (sometimes called a mutex or binary semaphore) is associated with each object and class. Once the java code is embedded with synchronized keyword, it is a monitor region.

    JVM Exceptions

    ArithmeticException, ArrayIndexOutOfBoundsException, ClassCastException, NullPointerException are thrown by the JVM and IllegalArgumentException, NumberFormatException are thrown by programmer. 

    JVM pre-allocated exceptions

    These are exceptions which are preallocated on the start of JVM. When method starts to throw (implicitly) one of these exceptions too frequently, JVM will notice that and for performance purposes, replace allocation of exception on every throw with throwing already preallocated exception without stacktrace.

    Shallow and retained sizes of Java Object

    Shallow size

    It is the amount of memory allocated to store the object itself, not taking into account the referenced objects. Shallow size of a regular (non-array) object depends on the number and types of its fields. Shallow size of an array depends on the array length and the type of its elements (objects, primitive types). Shallow size of a set of objects represents the sum of shallow sizes of all objects in the set.

    Retained size

    It is the object’s shallow size plus the shallow sizes of the objects that are accessible, directly or indirectly, ONLY from this object. In other words, the retained size represents the amount of memory that will be freed by the garbage collector when this object is collected.

    GC root objects

    The special nodes which will not be collected by Garbage Collector at the time of measuring the retained size of the object. The root kinds are:

    1. Class loaded by system class loader.

    2. Live threads

    3. Local variable or parameter of Java method

    4. Local variable or parameter of JNI method

    5. Global JNI reference

    6. Objects used as a monitor for synchronization

    7. Pre-allocated objects for exception handling

    8. Custom class loaders when they are in the process of loading classes

    The retained size of obj1 will be the sum of shallow sizes of obj1, obj2, and obj4. The retained size of obj2 will be the sum of shallow sizes of obj2 and obj4.