GC is a marvel of Java.
How to get GC Log so that we know what iss is happening , what is the foot print of execution phase image:
Let us explore the switches available for GC collection statistics in JVM
GC is a marvel of Java.
How to get GC Log so that we know what iss is happening , what is the foot print of execution phase image:
Let us explore the switches available for GC collection statistics in JVM
Network Commands
C:\Users\rmcme>ipconfig /all
Windows IP Configuration
Pinging amazon.com [205.251.242.103] with 32 bytes of data:
Garbage Collection : GC#2
Concurrent Mark Sweep :
Concurrent low pause collector, multiple threads are used for minor garbage collection.
Major GC is multi threaded and runs concurrently alongside application. Use more CPUS.
If you can allocate ore CPU, the CMS GC is a preferre3d chice for better performance.
Garbage Firs (G1):
Replacement for CMS
Designed for multi-threaded apps that have large heap size available (>4 GB)
Does not have separate regions for young and old generations.
Partition the heap in to a set of equal size regions and use multiple[le threads to scan them.
After mark phase is over, G1 knows which regions contains the most garbage objects and performs GC on those regions first.
Experimental Garbage Collectors.
Shenandoah: Release as part of JDK 12. GC cycle works currently with application threads. Can relocate objects concurrently. More CPU intensive.
ZGC : Release as part of JDK 11. Low latency, scalability and ease of use. Allows to application to continue running while it performs all garbage collection operations.
How to choose :
Factors : Most of the default setting will work.
Serial is fine for small data setup (>=100 MB) and or it will be run on a sigle processor with no-pause time requirements.
Parallel is preferable for peak performance for apps and with no-pause time requirements or pauses for 1 sec or longer are acceptable.
CMS/G1 is preferable is response time is important than overall throughput and garbage collection pauses must be kept shorter than approximately 1 sec.
Advantages of GC :
Best Practice:
It is possible to manually run the GC with System.gc() or Rintime.gc() methods.
If u don't have enough memory to run your application, you will experience slowdowns, hangs, long collection times, :stop the world" events, and eventually out of memory errors. You can take the help of monitoring tool like jstat or Java Flight recorder to see if the heap usage grows indefinitely, which might indicate a bug in your code.
If small, default settings will work.
Best approach to tuning JAVA garbage collection is settings flags on the JVM.
Garbage Collection - GC#1
Process of reclaiminh the runtime unused memory by destroying the un used objects
Methods like free() in C and deletete() in c++ are used to perform clean garbage.
In Java, GC is automatic during the life time of a program
At any point of RT, heap memory consistes of 2 types of objects:
Live : Being used and referenced
Dead : not used and not referenced currently.
How to derefernce objects:
By making a reference null { object o1 = null;}
By assigning a reference to another { object o1 = o2;}
By using an anonymous object { new Object;}
How GC Works:
Many Versions of JVM. has its own implementation of GC .
Any version of JVM can be used but should meet the std spec like :
: mark the unreachable objects
: Destroy them
: Compacting the memory.
GC Roots: to identify the live and dead objects
Local vars and input paramas
Active Threads
Static Fields of the Loaded classes
JNI In(ref)ferences
It traverse the full object graph in mem and marks live objects(visited). ALl not reacheble(not visited) by grtaph are identified as dead objects.
Sweep Phase and compact phase ( Fragmented mem blocks are made as contiguos blocks)
Generational GC strategy:
Marking will take a longer GC Time. All objects are mostly short lived.
Heap : (eden, S1, S2)
Young Generation : Newly
-Eden Space : all new objects start here, and initial mem is allocated to them
-Survivor Spaces : (S to S) - Objects are moved here from Eden after surviving one garbage collection cycle.
When eden space if filled , aminor GC is performed and all the survivir objects are moved to one of the survivor spaces.
Minor GC checks also the survivor space. All the dead objects are reoved when Minir GC is performed.
Second time Minor GC, is used Eden and Survivor space. At any point of time Survivor space is empty.
Old Generation : Long lived objects are eventually moved from the Young generation to the Old Generation.
This is also known as Tenured generation and conatins objects that have maintained in the survivor spaces for a long time.
When objects are garbage collected here, it is called as majot garbage collection event.
Permenant Generation :
Metat data such as classes and methods are stored in Perm Genearation
Classes thar are no longer in use may be GC from the permenant generation.
Now Metaspace memory soppace replaced the permenant generation. Heap is now automatically resized. Avoids the the pbm of apps going out of memory due to the limited size of
PermGen space of heap.
Classes that are no longer used is automatically cleaned when the metaspace searches its maximum size.
JVM
Java Virtual Machine implements Write once Run Anywhere approach
Supports many Scala, Kotlin in addition to Java
-> VM -> OS -> Application
Virtual M/C : H/W-> Hypervisor-> -> VM -> OS -> App..
-> VM -> OS -> App..
Java - Compiler - SC (Java) - > Byte code (class) ->
JVM :
Class Loader : Prepares the java classes and loads them into main memory.
Run Time Mem/ Data Area: Holds the the rT vars and Data
Execution Engine : Executes the code
Class Loader :
Loading : Boot strap Loader, Extension Class Loader, Application Class Loader
Bin representation :
Boot Strap Loader . Root Class Loader ..
Super class of Extension loads the std java packages like java.lang, java.net, java.util, java.io etc.
The above are available in rt.jar file
Extension Class Loader : Sub class of Bootstrap and the super class of thge Application class Loader.
Loads the files present in $JAVA_HOME/jre/lib/ext directory
Application Class Loader : subclass extensions loader, Loads the files present on the class path
By Default, the class path is set to the current directory of th application.
Linking :
Verification : Verify, Prepare and Resolve : check the structureal correctness of the .class file by checking it against a set of constraint rules . Check for Verify Exception..
Preperation : JVM allocates memory for stat fields of a class or interface. Initializes them with default values.
Resolution : Symbolic reference are substituted with direct references present in RT constant pool.
Initialization :
Clinit .
Run Time Data Area:
Method Area :
Class level data as RT Constant Pool, field and code for methods. Memory is insufficent for the startup, JVM throws outofMemoryError
Memory for class instances and arrays is allocated.
Heap Area :
All the objects and their corresponding instance varaiables and arrays are stored here. Created on startup. Only one heap Area/JVM
Stack Area :
PC Register : Program Counter Register. JVM supports multiple threads. Each thread has its own PCR, to hold the address of currently executing JVM Instruction.
Once executed, PCR is updated
Native Method Stack : JVM supports native methods. ( written in c/C++)
Execution Engine :
Byte code is loaded then interpreter
Garbage Collector:
Java Native Interface
Supports execution of native code via JNI (c, C++ or ASM files).
3 Steps
Focus on Learning of students rather than teaching
Teachers can quiz students weekly and reveal the correct answers immediately. In this way, students receive prompt and frequent feedback. They also have an incentive to complete assigned readings and pay attention in class.
Finally, teachers can take a page from video-gaming companies. Video gaming is a learned skill, and many gamers perform at a very high level. The makers of popular video games like Angry Birds and Super Mario exploit basic principles of learning. Players receive instantaneous feedback on their performance. They also gain expertise through repetition with variation. And leveling up is rewarding!
Key:
From Source
Ex 1 kivyApp1.py
Output
Ex 2: kivyApp2.py
Output
EX 3 : kivyApp3.py
Output :
Ex 4 : kivyApp4.py using .kv file
kvfile.kv
Output
KVBoxLayout.kv
Output:
Ex 6 : kivyApp6.py
output
Once you click hello world1 button, it changes to blue.
Ex 7 kivyApp7.kv
pagelayout.kv
# creating simple Pagelayout using.kv
output:
Pl refer kivy Tutorials :
1. Tutorials — Kivy 2.1.0 documentation
2. Kivy Tutorial - GeeksforGeeks
Mobile Tea/Coffee POS Chai POS Mobile Tea/Coffee & Snacks Billing ...