This document describes a testing framework for analyzing Java garbage collection (GC) performance. It consists of:
1. A properties file that specifies test parameters like the GC algorithm, heap size, and object lifetimes.
2. A script file that defines the sequence of object creations and workload.
3. Classes that execute the script, measure GC performance, and write output to log files.
4. A script that iterates the tests, varying a property each time and analyzing the results.
Java garbage collection has evolved significantly since its inception in 1959. The modern Hotspot JVM uses generational garbage collection with a young and old generation. It employs concurrent and parallel techniques like CMS to minimize pauses. OutOfMemoryErrors require increasing heap sizes or fixing leaks. Finalizers are generally avoided due to performance impacts. GC tuning must be tested under realistic loads rather than one-size-fits-all settings. Analysis tools help correlate GC logs with application behavior.
This document discusses Scribe and Thrift, log aggregation systems developed by Facebook. It provides an overview of Scribe, which is used to collect log data from different servers and applications. Scribe uses Thrift for its RPC communication and does not rely on a central server - if the central server is unavailable, log data will be stored locally and synced once the server is available again. The document also discusses installing and configuring Scribe and Thrift on a Linux system and implementing a simple logging example.
This presentation is primarily based on Oracle's "Java SE 6 HotSpot? Virtual Machine Garbage Collection Tuning" document.
This introduces how Java manages memory using generations, available garbage collectors and how to tune them to achieve desired performance.
GC Tuning in the HotSpot Java VM - a FISL 10 PresentationLudovic Poitou
?
This document provides a summary of a presentation on garbage collection tuning in the Java HotSpot Virtual Machine. It introduces the presenters and their backgrounds in GC and Java performance. The main points covered are that GC tuning is an art that requires experience, and tuning advice is provided for the young generation, Parallel GC, and Concurrent Mark Sweep GC. Monitoring GC performance and avoiding fragmentation are also discussed.
The document discusses Java garbage collection. It begins with an introduction to garbage collection, explaining that it is used to release unused memory and each JVM can implement its own garbage collection algorithms. It then covers the main garbage collection algorithms of reference counting, mark and sweep, and stop and copy. It also discusses finalize() methods, reference types in Java including strong, soft, weak and phantom references, and tips for improving garbage collection performance in Java programs.
Вячеслав Блинов ?Java Garbage Collection: A Performance Impact?Anna Shymchenko
?
This document discusses Java garbage collection and its performance impact. It provides an overview of garbage collection, including that garbage collectors reclaim memory from objects no longer in use. It describes the different Java GC algorithms like serial, parallel, CMS, and G1 collectors and how to choose between them based on factors like heap size and CPU availability. It also gives guidance on basic GC tuning techniques like sizing the heap and generations as well as using adaptive sizing controls.
Did you know your JDK contains visual monitoring tools with features like: Profiler, Visual GC, Heap dump browsing and much more?
VisualVM, BTrace and jhat are just some examples for useful performance diagnostics tools hidden in your JDK.
Join us for this session to see what tools are out there and how you can use them to identify and solve performance related issues.
The document contains log information from web server requests and access logs. It includes details like IP addresses, dates, request URLs, response codes, user agents, and referer URLs from multiple requests. The logs show information about requests for book information and search redirects.
This slide will explain about building blocks of JVM optimization for you java based application.
It explains basics of heap concepts and different type of java garbage collectors.
3. 什么是内存泄漏
? JAVA 存在内存泄漏
C 的例子:
int *pi; void foo() {
pi = (int*) malloc(8*sizeof(int)); // oops, memory leak of 4 ints
// use pi
free(pi); // foo() is done with pi
}
void main() {
pi = (int*) malloc(4*sizeof(int));
foo();
pi[0] = 10; // oops, pi is now a dangling pointer
}
4. Java 的例子
import java.io.IOException;
import java.util.HashSet;
import java.util.Random;
import java.util.Vector;
public class LeakExample {
static Vector myVector = new Vector();
static HashSet pendingRequests = new HashSet();
public void slowlyLeakingVector(int iter, int count) {
for (int i=0; i<iter; i++) {
for (int n=0; n<count; n++) {
myVector.add(Integer.toString(n+i));
}
for (int n=count-1; n>0; n--) {
// Oops, it should be n>=0
myVector.removeElementAt(n);
}
}
}
5. Java 的例子
public void leakingRequestLog(int iter) {
Random requestQueue = new Random();
for (int i=0; i<iter; i++) {
int newRequest = requestQueue.nextInt();
pendingRequests.add(new Integer(newRequest));
// processed request, but forgot to remove it
// from pending requests
}
}
public void noLeak(int size) {
HashSet tmpStore = new HashSet();
for (int i=0; i<size; ++i) {
String leakingUnit = new String("Object: " + i);
tmpStore.add(leakingUnit);
}
// Though highest memory allocation happens in this
// function, but all these objects get garbage
// collected at the end of this method, so no leak.
}
6. Java 的例子
public static void main(String[] args) throws IOException {
LeakExample javaLeaks = new LeakExample();
for (int i=0; true; i++) {
try { // sleep to slow down leaking process
Thread.sleep(1000);
} catch (InterruptedException e) { /* do nothing */ }
System.out.println("Iteration: " + i);
javaLeaks.slowlyLeakingVector(1000,10);
javaLeaks.leakingRequestLog(5000);
javaLeaks.noLeak(100000);
}
}
}