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.

Wednesday, September 28, 2011

My Logger is ready to use

This is your personal assistant and stays online 24x7x365.

My Logger(mylogger@followinstinct.com) is ready to use. It is a chat bot that you can add to your gmail or any XMPP based mail account. Once your account is active, you can save info with a tag and can retrieve it later by tag. IM is the simplest way to access and store information.

Signup Instructions:
  1. Invite mylogger@followinstinct.com to your chat account. It can be gmail or any XMPP based account. Thats it, you don't need to install any software or do any registration..
After your account is active. Instruction to use the application:
  1. To save data see the below example
    movie: Inception
    Here movie is the tag and Inception is the info to be saved. You can add any number of info to a single tag.
  2. To retrieve data by tag see the below example
    L movie
    Here you will get all the info associated wit the tag 'movie'.
  3. To retrieve all info irrespective of tag see below example
    L
    Yes, just l. It will list all the information you have saved.
  4. To retrieve all tags
    tags
  5. To remove the last information you entered
    undo
    You can keep doing undo any number of times, there is no limitation. Be warned there is NO REDO.
This project is not complete. Please send me your comments and suggestions at support@followinstinct.com.

Wednesday, July 20, 2011

Consequence is consistent with cause, no matter what!

Consequence is consistent with cause, no matter what! This is known to everyone, still I feel like repeating. What we are now is result of what we think, what we read, what see, whom we speak, whom we work with, the events we involved with and so on, which includes the entire world directly or indirectly. When the whole world is contributing towards us, what we need to do? Just manage where you want to get involved directly and where indirectly, because priority matters which in turn is outsourcing.

This is gist of 2 books I have read long back Outliers By Malcom Gladwell and Think and Grow Rich by Napoleon Hill

Sunday, June 26, 2011

Artifact creator, maven command generator

I have written this program for my own requirement. I feel it is a generic one. I have written a test program for adding a new feature, now I want to add that feature to my real application. I need to find what are the additional jars used, and create pom dependencies. This programs takes 2 required parameters and 1 optional parameter. Click here to download.

Parameter list
  1. Source1: Path to lib folder of the test program(required).
  2. Source2: Path to lib folder of the real program(required).
  3. Pom: Path where the output will be printed(optional), output can be seen from console.
Features
  1. List of jars available with same version.
  2. List of jars available with different version.
  3. Maven command for installing the new jars into maven repository.
Here is the command to use this program

java -jar artifact-creator-0.5.jar -s1 /path/of/lib/folder/of/test/program -s2 /path/of/lib/folder/of/real/program -pom /path/of/file/where/output/printed/optional