[BAEL-10866] - Resolved conflicts
This commit is contained in:
+1
-8
@@ -14,25 +14,20 @@
|
||||
- [Pattern Search with Grep in Java](http://www.baeldung.com/grep-in-java)
|
||||
- [URL Encoding and Decoding in Java](http://www.baeldung.com/java-url-encoding-decoding)
|
||||
- [How to Create an Executable JAR with Maven](http://www.baeldung.com/executable-jar-with-maven)
|
||||
- [How to Design a Genetic Algorithm in Java](http://www.baeldung.com/java-genetic-algorithm)
|
||||
- [Basic Introduction to JMX](http://www.baeldung.com/java-management-extensions)
|
||||
- [AWS Lambda With Java](http://www.baeldung.com/java-aws-lambda)
|
||||
- [Introduction to Nashorn](http://www.baeldung.com/java-nashorn)
|
||||
- [Java Money and the Currency API](http://www.baeldung.com/java-money-and-currency)
|
||||
- [JVM Log Forging](http://www.baeldung.com/jvm-log-forging)
|
||||
- [Guide to sun.misc.Unsafe](http://www.baeldung.com/java-unsafe)
|
||||
- [How to Perform a Simple HTTP Request in Java](http://www.baeldung.com/java-http-request)
|
||||
- [How to Add a Single Element to a Stream](http://www.baeldung.com/java-stream-append-prepend)
|
||||
- [Kotlin Java Interoperability](http://www.baeldung.com/kotlin-java-interoperability)
|
||||
- [How to Find all Getters Returning Null](http://www.baeldung.com/java-getters-returning-null)
|
||||
- [How to Get a Name of a Method Being Executed?](http://www.baeldung.com/java-name-of-executing-method)
|
||||
- [Converting a Stack Trace to a String in Java](http://www.baeldung.com/java-stacktrace-to-string)
|
||||
- [Introduction to Java Serialization](http://www.baeldung.com/java-serialization)
|
||||
- [Guide to UUID in Java](http://www.baeldung.com/java-uuid)
|
||||
- [Guide to Escaping Characters in Java RegExps](http://www.baeldung.com/java-regexp-escape-char)
|
||||
- [Difference between URL and URI](http://www.baeldung.com/java-url-vs-uri)
|
||||
- [Broadcasting and Multicasting in Java](http://www.baeldung.com/java-broadcast-multicast)
|
||||
- [Period and Duration in Java](http://www.baeldung.com/java-period-duration)
|
||||
- [OutOfMemoryError: GC Overhead Limit Exceeded](http://www.baeldung.com/java-gc-overhead-limit-exceeded)
|
||||
- [Creating a Java Compiler Plugin](http://www.baeldung.com/java-build-compiler-plugin)
|
||||
- [Quick Guide to Java Stack](http://www.baeldung.com/java-stack)
|
||||
@@ -41,9 +36,8 @@
|
||||
- [A Guide to ThreadLocalRandom in Java](http://www.baeldung.com/java-thread-local-random)
|
||||
- [Compiling Java *.class Files with javac](http://www.baeldung.com/javac)
|
||||
- [A Guide to Iterator in Java](http://www.baeldung.com/java-iterator)
|
||||
- [The Trie Data Structure in Java](http://www.baeldung.com/trie-java)
|
||||
- [Introduction to Javadoc](http://www.baeldung.com/javadoc)
|
||||
- [Guide to Externalizable Interface in Java](http://www.baeldung.com/java-externalizable)
|
||||
- [Guide to the Externalizable Interface in Java](http://www.baeldung.com/java-externalizable)
|
||||
- [A Practical Guide to DecimalFormat](http://www.baeldung.com/java-decimalformat)
|
||||
- [How to Detect the OS Using Java](http://www.baeldung.com/java-detect-os)
|
||||
- [ASCII Art in Java](http://www.baeldung.com/ascii-art-in-java)
|
||||
@@ -84,7 +78,6 @@
|
||||
- [Understanding Memory Leaks in Java](https://www.baeldung.com/java-memory-leaks)
|
||||
- [A Guide to SimpleDateFormat](https://www.baeldung.com/java-simple-date-format)
|
||||
- [SSL Handshake Failures](https://www.baeldung.com/java-ssl-handshake-failures)
|
||||
- [Implementing a Binary Tree in Java](https://www.baeldung.com/java-binary-tree)
|
||||
- [Changing the Order in a Sum Operation Can Produce Different Results?](https://www.baeldung.com/java-floating-point-sum-order)
|
||||
- [Java – Try with Resources](https://www.baeldung.com/java-try-with-resources)
|
||||
- [Abstract Classes in Java](https://www.baeldung.com/java-abstract-class)
|
||||
|
||||
Binary file not shown.
@@ -1,2 +1 @@
|
||||
### Relevant Articles:
|
||||
- [SHA-256 Hashing in Java](http://www.baeldung.com/sha-256-hashing-java)
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.baeldung.gc;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* A simple Java program to demonstrate how to enable verbose Garbage Collection (GC) logging.
|
||||
* <p>
|
||||
* This simple program loads 3 million {@link java.lang.String} instances into a {@link java.util.HashMap}
|
||||
* object before making an explicit call to the garbage collector using <code>System.gc()</code>.
|
||||
* <p>
|
||||
* Finally, it removes 2 million of the {@link java.lang.String} instances from the {@link java.util.HashMap}.
|
||||
* We also explicitly use <code>System.out.println</code> to make interpreting the output easier.
|
||||
* <p>
|
||||
* Run this program with the following arguments to see verbose GC logging in its complete form:
|
||||
* <pre>
|
||||
* -XX:+UseSerialGC -Xms1024m -Xmx1024m -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps -Xloggc:/path/to/file/gc.log
|
||||
* </pre>
|
||||
* Where:
|
||||
* <ul>
|
||||
* <li><code>-XX:+UseSerialGC</code> - specify the serial garbage collector.</li>
|
||||
* <li><code>-Xms1024m</code> - specify the minimal heap size.</li>
|
||||
* <li><code>-Xmx1024m</code> - specify the maximal heap size.</li>
|
||||
* <li><code>-verbose:gc</code> - activate the logging of garbage collection information in its simplest form.</li>
|
||||
* <li><code>-XX:+PrintGCDetails</code> - activate detailed information about garbage collection.</li>
|
||||
* <li><code>-XX:+PrintGCTimeStamps</code> - include a timestamp in the output reflecting the real-time passed in seconds since the JVM started.</li>
|
||||
* <li><code>-XX:+PrintGCDateStamps</code> - include the absolute date and time at the start of each line.</li>
|
||||
* <li><code>-Xloggc</code> - by default the GC log is written to stdout. Specify an output file via this argument.</li>
|
||||
* </ul>
|
||||
* <p>
|
||||
* It should be noted that the first three arguments are not strictly necessary but for the purposes or the example
|
||||
* help really simplify things.
|
||||
*
|
||||
*/
|
||||
public class VerboseGarbageCollectorRunner {
|
||||
|
||||
private static Map<String, String> stringContainer = new HashMap<>();
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Start of program!");
|
||||
String stringWithPrefix = "stringWithPrefix";
|
||||
|
||||
// Load Java Heap with 3 M java.lang.String instances
|
||||
for (int i = 0; i < 3000000; i++) {
|
||||
String newString = stringWithPrefix + i;
|
||||
stringContainer.put(newString, newString);
|
||||
}
|
||||
System.out.println("MAP size: " + stringContainer.size());
|
||||
|
||||
// Explicit GC!
|
||||
System.gc();
|
||||
|
||||
// Remove 2 M out of 3 M
|
||||
for (int i = 0; i < 2000000; i++) {
|
||||
String newString = stringWithPrefix + i;
|
||||
stringContainer.remove(newString);
|
||||
}
|
||||
|
||||
System.out.println("MAP size: " + stringContainer.size());
|
||||
System.out.println("End of program!");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.baeldung.nativekeyword;
|
||||
|
||||
public class DateTimeUtils {
|
||||
|
||||
public native String getSystemTime();
|
||||
|
||||
static {
|
||||
System.loadLibrary("nativedatetimeutils");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.baeldung.nativekeyword;
|
||||
|
||||
import com.baeldung.nativekeyword.DateTimeUtils;
|
||||
|
||||
public class NativeMainApp {
|
||||
public static void main(String[] args) {
|
||||
DateTimeUtils dateTimeUtils = new DateTimeUtils();
|
||||
String input = dateTimeUtils.getSystemTime();
|
||||
System.out.println("System time is : " + input);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.baeldung.nativekeyword;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
public class DateTimeUtilsManualTest {
|
||||
|
||||
private static final Logger LOG = org.slf4j.LoggerFactory.getLogger(DateTimeUtilsManualTest.class);
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpClass() {
|
||||
System.loadLibrary("msvcr100");
|
||||
System.loadLibrary("libgcc_s_sjlj-1");
|
||||
System.loadLibrary("libstdc++-6");
|
||||
System.loadLibrary("nativedatetimeutils");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenNativeLibsLoaded_thenNativeMethodIsAccessible() {
|
||||
DateTimeUtils dateTimeUtils = new DateTimeUtils();
|
||||
LOG.info("System time is : " + dateTimeUtils.getSystemTime());
|
||||
assertNotNull(dateTimeUtils.getSystemTime());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user