Wednesday, March 30, 2016
Tuesday, March 29, 2016
Postgres work_mem tutorial
- http://www.depesz.com/2011/07/03/understanding-postgresql-conf-work_mem/
- http://dba.stackexchange.com/questions/27893/increasing-work-mem-and-shared-buffers-on-postgres-9-2-significantly-slows-down
- http://dba.stackexchange.com/questions/41075/posgresql-setting-high-work-mem-does-not-avoid-disk-merge
SET ENABLE_SEQSCAN TO OFF;
show work_mem;
SET work_mem = '800MB';
query
RESET work_mem;
SET local work_mem = '800MB';
Monday, March 28, 2016
PostgreSQL performance Analysis
- http://engineering-blog.alphasights.com/how-to-stop-worrying-and-love-the-index/
- http://stackoverflow.com/questions/6592626/what-is-a-bitmap-heap-scan-in-a-query-plan
- https://devcenter.heroku.com/articles/postgresql-indexes
- http://michael.otacoo.com/postgresql-2/postgres-9-4-feature-highlight-lossyexact-pages-for-bitmap-heap-scan/
- http://pglearner.blogspot.com/2015/01/learning-bitmap-index-scan-recheck-cond.html
- http://www.postgresql.org/message-id/12553.1135634231@sss.pgh.pa.us
- http://dba.stackexchange.com/questions/119386/understanding-bitmap-heap-scan-and-bitmap-index-scan?newreg=52a072b9a8fa49fc989ed058adda8505
- http://dba.stackexchange.com/questions/106264/recheck-cond-line-in-query-plans-with-a-bitmap-index-scan
- http://stackoverflow.com/questions/410586/what-is-the-difference-between-seq-scan-and-bitmap-heap-scan-in-postgres
- http://stackoverflow.com/questions/10145037/understanding-postgres-explain-w-bitmap-heap-index-scans
- http://ask.use-the-index-luke.com/questions/148/why-is-this-postgres-query-doing-a-bitmap-heap-scan-after-the-index-scan
- http://www.postgresql.org/docs/8.1/static/performance-tips.html
- http://www.tech-recipes.com/rx/47637/inner-and-left-outer-join-with-where-clause-vs-on-clause/
- http://stackoverflow.com/questions/15706112/why-and-when-a-left-join-with-condition-in-where-clause-is-not-equivalent-to-the
- http://stackoverflow.com/questions/4752455/left-join-with-where-clause
- https://www.digitalocean.com/community/tutorials/how-to-create-remove-manage-tables-in-postgresql-on-a-cloud-server
- https://momjian.us/main/writings/pgsql/aw_pgsql_book/node195.html
- http://www.revsys.com/writings/postgresql-performance.html
- http://genius.com/Genius-engineering-team-one-weird-trick-to-make-postgresql-15000x-faster-annotated
- https://en.wikipedia.org/wiki/Bitmap_index
- http://stackoverflow.com/questions/6592626/what-is-a-bitmap-heap-scan-in-a-query-plan
- http://engineering-blog.alphasights.com/how-to-stop-worrying-and-love-the-index/
- http://www.postgresql.org/message-id/6638.1456795348@sss.pgh.pa.us
- https://www.datadoghq.com/blog/100x-faster-postgres-performance-by-changing-1-line/
- http://stackoverflow.com/questions/6777456/list-all-index-names-column-names-and-its-table-name-of-a-postgresql-database
- https://devcenter.heroku.com/articles/postgresql-indexes
- http://www.tutorialspoint.com/postgresql/postgresql_indexes.htm
- https://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server
- https://developers.google.com/identity/protocols/OAuth2InstalledApp#handlingtheresponse
Sunday, March 27, 2016
Saturday, March 26, 2016
Tuesday, March 22, 2016
Hibernate Performance Tuning
- http://stackoverflow.com/questions/35323950/hibernate-associations-using-too-much-memory
- http://www.mkyong.com/hibernate/hibernate-fetching-strategies-examples/
- https://developer.jboss.org/wiki/AShortPrimerOnFetchingStrategies
- https://dzone.com/articles/lazyeager-loading-using
- http://www.laliluna.com/articles/java-persistence-hibernate/performance-tips-hibernate-java-persistence.html
- http://blog.jhades.org/performance-tuning-of-spring-hibernate-applications/
- http://www.thoughts-on-java.org/tips-to-boost-your-hibernate-performance/
- http://arnosoftwaredev.blogspot.com/2011/01/hibernate-performance-tips.html
- http://arnosoftwaredev.blogspot.com/2011/01/fetching-strategies-in-hibernate.html
- http://vladmihalcea.com/2013/10/17/hibernate-facts-the-importance-of-fetch-strategy/
- http://what-when-how.com/hibernate/optimizing-fetching-and-caching-hibernate/
- http://www.laliluna.com/articles/java-persistence-hibernate/performance-tips-hibernate-java-persistence.html
- https://dzone.com/articles/hibernate-performance-tuning
Monday, March 21, 2016
hibernate improve database performance
hibernate improve database performance
- In the query string, you should use jdbc placeholder? Or use named parameters: Do not use the query string value instead of the very values.
- Flush affect performance, frequently refreshed affect performance, minimize unnecessary refresh.
- Cascade strategy, a few to several relationships set correctly cascade strategy, to think clearly in the operation target A cascade operation, while the need for an object B, such as one to many relationship between father and son, the father removed one, required level United delete child many, this time can be set to one end of this cascade = "delete", so when you delete one, the child is automatically deleted, but the pair does not affect the parent. Cascade has other property values, as long as the settings are correct, you can improve performance.
- Lazy policy set correctly delay loading strategy will also enhance the performance, one to many or many to many, the total delay should normally be loaded into the memory of many of the party. Set lazy = "true", first send sql statements to load itself into memory only when needed to load Cascading objects; lazy = "false", is simultaneously loaded into memory objects themselves and cascade.
- In addition to the performance of the collection (set, list, map, array ), should be set up correctly.
- The proper use of third-party cache, read frequently writes small operating conditions, the use of third-party cache can significantly improve performance, such as ehcache caching strategies have: read-only, read-write and notstrict-read-write.
Friday, March 18, 2016
Omio Bani
A string doesn't have an encoding - or it's always UTF-16, if you want to think of it like that. There's no such thing as "a UTF8 string". If you've converted some binary data into a String using the wrong encoding, you're in trouble already
Hash maps only use hash codes to find keys efficiently. When you ask the map to find a value, it basically has to iterate over all its entries, at which point there's no point in using
hashCode()
, so it just calls equals
.
If you try the map the other way round, with
Test
as the key instead of the value, that won't work without overriding hashCode
.Wednesday, March 16, 2016
java.lang.IllegalStateException while starting Tomcat Server
on Spring with Hibernate application, application is working fine but while starting tomcat server, im getting below Exception.
Can anybody explain why this exception occurring and how to resolve it??
INFO: Illegal access: this web application instance has been stopped already. Could not load java.net.BindException. The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
java.lang.IllegalStateException
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1600)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
at com.mysql.jdbc.SQLError.createLinkFailureMessageBasedOnHeuristics(SQLError.java:1220)
at com.mysql.jdbc.exceptions.jdbc4.CommunicationsException.<init>(CommunicationsException.java:57)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1074)
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3270)
at com.mysql.jdbc.MysqlIO.quit(MysqlIO.java:1659)
at com.mysql.jdbc.ConnectionImpl.realClose(ConnectionImpl.java:4296)
at com.mysql.jdbc.ConnectionImpl.cleanup(ConnectionImpl.java:1265)
at com.mysql.jdbc.ConnectionImpl.finalize(ConnectionImpl.java:2667)
at java.lang.System$2.invokeFinalize(Unknown Source)
at java.lang.ref.Finalizer.runFinalizer(Unknown Source)
at java.lang.ref.Finalizer.access$100(Unknown Source)
at java.lang.ref.Finalizer$FinalizerThread.run(Unknown Source)
Answer:
I want to give you couple of choices. You can try it. Any option can fulfill your demand.
Restart your tomcat and apache server
because a long time of using, it keeps older version of your application.- Clean your tomcat
temp
directory andrestart
- As stated in error,
The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
It may be the real cause that at this moment you are in debugging mode and it doesn't clear the running thread. so remove your break point and run it not debugging
- If your code contains any kind of thread which are not properly terminated, then this type of error may occur. That you have
init()
method but nodestroy()
method, then this type of error may occur. For details, you can follow the link -http://www.javaspecialists.eu/archive/Issue056.html - if the
webapp has stopped, or is stopping
, that means that the.war
file orWEB-INF/web.xml
timestamp changed, and the webapp might be reloading. Please check timestamp is OK or not. - To turn it off, set reloadable="false" in the context definition of your app. It might be tomcat's
server.xml
. In details solution: The tomcat's server.xml of the reloadable Context is set to false. For example:
Context path="/expert" docBase="expert" debug="0" reloadable ="false"/>
The solution is easy, as long as the tomcat's server.xml in
reloadable = "true" into false
on the line, but to do so would lose the advantage of hot deployment, and for the development is not very convenient, simply change it or not. This error does not matter.
Error principle:
The reason is because the tomcat restart, because the previous tomcat thread has not completely shut down, restart tomcat will report this exception, but this does not affect the normal use, just jump abnormal annoying people. Used hibernate, spring or other large components, when a WEB application system has a lot of class,
if you turned the Tomcat
reloadable = true
, then whenever the relevant documents change, Tomcat stops web app and frees up memory, and then reload web app. it may be a huge project. So we always think if there is only a certain class of overloaded functions, will greatly meet our debugger.UPDATE: For code related issue
First, I want to tell you that I have given you some solutions for tomcat basis. Now I want to give you a solution for code basis. Would you please cross check your code with this issue? Please follow the URL.
UPDATE: For MySQL related issue
- There are 2 issues.
- This web application instance has been stopped already. Could not load
java.net.BindException
. - This web application instance has been stopped already.Could not load
com.mysql.jdbc
.
This is because the MySQL JDBC driver on the application under the
WEB-INF/lib
directory, in the re-release of its loaded twice, so long as it can be copied to %TOMCAT_HOME%/lib
can solve the problem. We can solve these two anomalies MySQL drivers from the WEB-INF/lib
folder moved to%TOMCAT_HOME%/lib
.- I suspect this might be happening after the web application is restarted, where it's down for a short period of time. Then some
finalize()
method in the code is probably trying to do some cleanup too late. Whether or not that's in your code or the MySQL driver I can't say. You definitely should only have one version of a jar in a directory at a time. You might want to upgrade it to the latest (5.1.38 right now) in case something has been fixed that might be affecting you.(Number 9 is copied from @WhiteFang34)
Related link for 9: tomcat 6.0.24 Exception: Could not load com.mysql.jdbc.SQLError
Monday, March 14, 2016
Java Geeks
- http://stackoverflow.com/users/2970947/elliott-frisch
- http://stackoverflow.com/users/139985/stephen-c(for performance, java, multithreading, string)
- http://stackoverflow.com/users/57695/peter-lawrey(for performance, java, multithreading, string and array)
- http://stackoverflow.com/users/2513573/adamskywalker
- http://stackoverflow.com/users/1235929/dave
- http://stackoverflow.com/users/642706/basil-bourque - for time related section.
- http://stackoverflow.com/users/42769/adeel-ansari -(for java, servlet, jsp, spring, hibernate)
- http://stackoverflow.com/users/135152/omg-ponies - for(sql, mysql, oracle)
- http://stackoverflow.com/users/597657/eng-fouad
- http://stackoverflow.com/users/1707091/rgettman - (for java, generics)
- http://stackoverflow.com/users/12960/brian-agnew - (for java, linux, shell, bash)
- http://stackoverflow.com/users/995876/esailija - (for javascript, jquery, node.js)
- http://stackoverflow.com/users/10397/justin-cave - (oracle kid from MIT)
- http://stackoverflow.com/users/2696260/m-deinum -Real spring panda
- http://stackoverflow.com/users/1393484/ali-dehghani - Spring-boot, spring, spring-mvc
- http://stackoverflow.com/users/438154/sotirios-delimanolis - Spring, Spring-MVC, Java, Multithreading, generics.
- http://stackoverflow.com/users/47281/marcus-leon
Sunday, March 13, 2016
Friday, March 11, 2016
Regular Expression(Regex), No Tension
Study Area:
- http://regexone.com/
- http://www.regular-expressions.info/
- http://stackoverflow.com/tags/regex/info
- http://stackoverflow.com/questions/22937618/reference-what-does-this-regex-mean
Running and Checking Area:
Original Link:http://stackoverflow.com/questions/35945383/find-consequent-row-of-numbers-seprated-by-non-alphabetic-charachters-and-coun
For Java 7:
For Java 7:
Thursday, March 10, 2016
input miss match exception
https://examples.javacodegeeks.com/java-basics/exceptions/java-util-inputmismatchexception-how-to-solve-inputmismatchexception/
Wednesday, March 9, 2016
How toto make LinkedHashMap thread safe?
java.util.Collections.synchronizedMap(map) returns a synchronized (thread-safe) map backed by the specified map.
You can anonymously extend
LinkedHashMap
to change the behavior of removeEldestEntry(...)
, then wrap the instance of the anonymous class in a synchronized map. You didn't mention what type parameters you require, so I'm using <String, Integer>
in this example.Map<String, Integer> map = Collections.synchronizedMap(new LinkedHashMap<String, Integer>() {
private static final long serialVersionUID = 12345L; // use something random or just suppress the warning
@Override
protected boolean removeEldestEntry(Entry<String, Integer> eldest) {
return size() > MAX_SIZE; // how many entries you want to keep
}
});
Original Link:http://stackoverflow.com/questions/28653889/java-thread-safe-linkedhashmap-implementation
IOC containers and DI pattern
- http://www.martinfowler.com/articles/injection.html
- http://martinfowler.com/bliki/InversionOfControl.html
- http://stackoverflow.com/questions/6550700/inversion-of-control-vs-dependency-injection
- https://msdn.microsoft.com/en-us/library/aa973811.aspx
- http://buraktas.com/cdi-dependency-injection-producer-method-example/
Tuesday, March 8, 2016
Heap Space Vs Permgen Space
Simply
- Heap space: All live objects are allocated here.
- Stack space: Stores references to the object for variable in method call or variable instantiation.
- Perm space: Stores loaded classes information
For example:
Student std = new Student();
after executing the line above memory status will be like this.
- Heap: stores "new Student()"
- Stack: stores information about "std"
- Perm Space: stores information about Student class
Heap Space:
java.lang.OutOfMemoryError:Java heap space
Java applications are only allowed to use a limited amount of memory. This limit is specified during application startup. To make things more complex, Java memory is separated into two different regions. These regions are called Heap space and Permgen (for Permanent Generation):
The size of those regions is set during the Java Virtual Machine (JVM) launch and can be customized by specifying JVM parameters -Xmx and -XX:MaxPermSize. If you do not explicitly set the sizes, platform-specific defaults will be used.
The java.lang.OutOfMemoryError: Java heap space error will be triggered when the application attempts to add more data into the heap space area, but there is not enough room for it.
Note that there might be plenty of physical memory available, but thejava.lang.OutOfMemoryError: Java heap space error is thrown whenever the JVM reaches the heap size limit.
What is causing it?
There most common reason for the java.lang.OutOfMemoryError: Java heap space error is simple – you try to fit an XXL application into an S-sized Java heap space. That is – the application just requires more Java heap space than available to it to operate normally. Other causes for this OutOfMemoryError message are more complex and are caused by a programming error:
- Spikes in usage/data volume. The application was designed to handle a certain amount of users or a certain amount of data. When the number of users or the volume of data suddenly spikes and crosses that expected threshold, the operation which functioned normally before the spike ceases to operate and triggers the java.lang.OutOfMemoryError: Java heap space error.
- Memory leaks. A particular type of programming error will lead your application to constantly consume more memory. Every time the leaking functionality of the application is used it leaves some objects behind into the Java heap space. Over time the leaked objects consume all of the available Java heap space and trigger the already familiar java.lang.OutOfMemoryError: Java heap space error.
Permgen space:
java.lang.OutOfMemoryError:Permgen space
Java applications are only allowed to use a limited amount of memory. The exact amount of memory your particular application can use is specified during application startup. To make things more complex, Java memory is separated into different regions which can be seen in the following figure:
The size of all those regions, including the permgen area, is set during the JVM launch. If you do not set the sizes yourself, platform-specific defaults will be used.
The java.lang.OutOfMemoryError: PermGen space message indicates that thePermanent Generation’s area in memory is exhausted.
What is causing it?
To understand the cause for the java.lang.OutOfMemoryError: PermGen space, we would need to understand what this specific memory area is used for.
For practical purposes, the permanent generation consists mostly of class declarations loaded and stored into PermGen. This includes the name and fields of the class, methods with the method bytecode, constant pool information, object arrays and type arrays associated with a class and Just In Time compiler optimizations.
From the above definition you can deduce that the PermGen size requirements depend both on the number of classes loaded as well as the size of such class declarations. Therefore we can say that the main cause for the java.lang.OutOfMemoryError: PermGen space is that either too many classes or too big classes are loaded to the permanent generation.
Resource Link:
- https://plumbr.eu/outofmemoryerror/java-heap-space
- https://plumbr.eu/outofmemoryerror/permgen-space
- http://stas-blogspot.blogspot.in/2011/07/most-complete-list-of-xx-options-for.html#UseConcMarkSweepGC
- https://www.javacodegeeks.com/2013/12/decoding-java-lang-outofmemoryerror-permgen-space.html
- http://www.javavillage.in/reasons-outofmemory-permespace.php
- https://docs.oracle.com/javase/7/docs/webnotes/tsg/TSG-VM/html/memleaks.html
- http://www.dynatrace.com/en/javabook/other-java-memory-issues.html
Subscribe to:
Posts (Atom)