Saturday, November 24, 2012

JVM Memory management: Garbage Collection



Most of the questions related to memory would have been answered by the image above. There are two and only two major partitions in JVM memory, Heap and Non-Heap. All the other type of memory space or pools we have heard belong to either of these two. Java specification does not enforce any specific implementation of memory, it depends on JVM implementation. The JVM of Oracle is named HotSpot.


Young Generation:
Here garbage collection is frequent and less expensive.
Eden Space: Initially all objects created here.
Survivor space: Contains objects that survived garbage collection in Eden Space

Old Generation:
Here garbage collection is less frequent and expensive.
Tenured Space: The objects survived the garbage collection get moved here.
PermGen: Contains meta data of the virtual machine, class and method objects.

Garbage Collector:
It is a low priority daemon thread. It frees memory of any object that is not reachable from a live thread. We can suggest JVM to do garbage collection by calling Runtime.getRuntime().gc() or System.gc() which internally calls Runtime.getRuntime().gc(). Runtime is singleton. We can configure type of garbage collector to be used by passing command line arguments to JVM. For more details on garbage collection http://www.oracle.com/technetwork/java/gc-tuning-5-138395.html 

To configure stack memory  -Xss1m
To configure heap memory  -Xmx512m -XX:MaxPermSize=256m



Sunday, August 26, 2012

Advantage of distraction


Mid term exam is approaching, I need an excuse to procrastinate studying. I wanted a countdown timer that shows me how much time left for preparation and how many hours required per day. I could not find easily, so made a small HTML5 gadget. It works offline, and only offline as of now.

 Advantage of distraction is that I learned how to make the HTML5 gadget work offline. Also how to make a windows sidebar gadget, as the initial ideas was to make a windows gadget.

Here is how to develop a Windows sidebar gadget. http://msdn.microsoft.com/en-us/library/windows/desktop/bb456468%28v=vs.85%29.aspx

It's easy to make a web page work offline. Below is the code, write that in the page you want to make work offline.

<html manifest="cache-manifest">

Now create the manifest file with name "cache-manifest" and write the below code in it

CACHE MANIFEST
page1.html
my-script.js


And finally how to write HTML code inside a blog post :)

Wednesday, June 13, 2012

Insights of Snap Judgement

Taking decisions involving emotions is like solving an open ended problem, in either case we don't get a logical concrete solution. I feel avoiding such situations are almost impossible. Most of the time this involves snap judgement without much details of the context. Psychologists working on subconscious mind say somehow brain got a system developed to function in such situations and we should not interfere with that. As  Malcolm Gladwell has written in his book Blink "Introspection destroys the ability to solve insight problems. Introspection messes up with our reactions." It's simple we can not always rationalize and explain our feelings. e.g Why we are attracted to someone, why we  like certain food etc.

The system in brain is reliable most of the time but not always, such error are called Warren Harding Error. One more example is  http://en.wikipedia.org/wiki/Amadou_Diallo_shooting. A different flavor of this error is volume of info may always not help, best example is divorce, despite the fact that people collect lot of fact on  their spouse.

Difficulty here is, when, what and how much info to collect. Even if want, it may not be possible all the time because of time constraint and complexity of understanding the opponents intention.

Conclusion:
Need to rely on the system brain already has. The core of that system is Implicit Association, so we can work on this, read more, observe more, listen carefully..........

Saturday, April 7, 2012

Rethinking Think and Grow Rich

Any theory or opinion works only with specific audience and in particular context. Vision, recognition of problem, decision making skill etc are important for doing business. Think and Grow Rich says experts are in every corner of the world use them instead of being one more expert. First need to decide if you want to be an expert or someone you use the experts.