Saturday, 26 December 2015

java.lang.OutOfMemoryError The 8 symptoms that surface them

Tutorial content:
java.lang.OutOfMemoryError: Java heap space
java.lang.OutOfMemoryError: GC overhead limit exceeded
java.lang.OutOfMemoryError: Permgen space
java.lang.OutOfMemoryError: Metaspace
java.lang.OutOfMemoryError: Unable to create new native thread
java.lang.OutOfMemoryError: Out of swap space?
java.lang.OutOfMemoryError: Requested array size exceeds VM limit

Source:
or

Sunday, 29 November 2015

Instagram API search by tag doesn't return anything

I created new app on instagram and tried to get all images by tag, following api call was used:

/tags/{tag-name}/media/recent.

As a result i received empty list, with message in pagination: depreciationWarning=next_max_id and min_id are deprecated for this endpoint; use min_tag_id and max_tag_id instead.

It took me a while to get that apps in sandbox mode (starting November 2015) has some limitations. Here what documentation says:

"As another example, let's consider an endpoint that returns a list of media: /tags/{tag-name}/media/recent. The response returned by this endpoint will contain only media with the given tag, as expected. But instead of returning media from any public Instagram user, it will return only media that belongs to your sandbox users, restricted to the last 20 for each user."

PS: I used cool library called jInstagram https://github.com/sachin-handiekar/jInstagram

Friday, 20 November 2015

Monday, 26 October 2015

Microservices with Spring

Spring cloud is set of tools that helps you to build your application in "Microservice way". Here is short tutorial that spring published. More about microservices in dzone article.

Thursday, 14 May 2015

WARNING: Could not initialize OpenglES emulation, using software renderer

When I am running android emulator(from Android studio) I am getting bellow error:

emulator: WARNING: Could not initialize OpenglES emulation, using software renderer

This was due my switchable graphics, so my laptop has two video cards. And by default intel video was used. When I switched to the ATI video everything worked great.

Sunday, 15 March 2015

Saturday, 14 March 2015

Hunting Memory Leaks in Java & memory problems notes

Good article about general approach of finding leaks
http://www.toptal.com/java/hunting-memory-leaks-in-java

1) In every jvm should be enabled following flags, to gather statistics:

-XX:-PrintGCDetails 
-XX:+PrintGCTimeStamps-Xloggc:gc.log or -verbose:gc
2) To read gc logs https://github.com/chewiebug/GCViewer
metrics:
throughout - the percent that your application works vs garbage collector
largest pause - the pause when gc works and your app is not responding

3) most used ways to solve memory problems

a) solve memory leaks problems, see article
b) Xmxn - enlarge heap size
c) change garbage collector algo, in general about GC's
Parallel GC - bad largest pause but good throughout
CMS - good pause but bad throughout
G1 - soon will be default, should be used from jvm8+, for jvm 7 still not so good


sometimes:
-XX:OldSize - the amout of data alive after Major GC, should be:
   for Parallel GC  XX:OldSize = LiveSet * (1,2 - 1,5)
   for CMS GC XX:OldSize = LiveSet * 2
^where LiveSet - amout of memory after Major GC

More links:
 

More about verbosegc

Dump heap to file when java.lang.OutOfMemoryError is throw 

-XX:+HeapDumpOnOutOfMemoryError and use Heap Analyzer tool

Sunday, 25 January 2015

Disable jsp compilation on Tomcat

For performance reasons it could be useful to disable jsp compilation (in runtime), and do pre-compilation. In tomcat you can disable it in the tomcat\conf\web.xml, see line with org.apache.jasper.servlet.JspServlet.