Feeds:
Posts
Comments

A picture is worth 1000 words. This safe has been through a lot. Tell its story. Image credit: “safe” – © 2007 Paul Keller – made available under Attribution 2.0 Generic

Singing with Strings


 

The title: Singing is all about memory the lyrics, the tune, the music etc. done all these properly “you sing well”…so let us discuss something of memory perspective of String.

String is a unique object in Java. The Java Specification explains several unique properties of String in Java. We might already know some of them. First, String is unique because it can be created without new keyword, like example below.

String s = “new String”;

I have to mention that you can still create String object using new keyword, like this:

String s = new String(“new String”);

Does both statement “exactly equals”? Well, most of you also know that this is not true. The first example will try to reuse the same object whenever possible (and is correct because String is immutable) while the second will force the creation of new String object. Consider this example:

System.out.println(“b” == “b”);

System.out.println(new String(“b”) == new String(“b”));

The result of first example is “true” while the second one will give “false”.

I almost certain that experienced programmer will never create String using new in normal use. But sometime, we are forced to use that. One case that I can think of is when you parse an XML file using SAX parser.

public class Reader extends DefaultHandler {

private ListlistString = new ArrayList();

public void characters(char[] ch, int start, int length) throws SAXException {

String content = new String(ch, start, length);

listString.add(content);

}

}

This example works correctly but is not efficient. Once you have a document like this:

<test>

<string>String</string>

<string>String</string>

<string>String</string>

<string>String</string>

<string>String</string>

<string>String</string>

<string>String</string>

<string>String</string>

<string>String</string>

<string>String</string>

</test>

Try to profile your application, force garbage collection and you will still have ten String objects left in the memory.

Fortunately, Java has provided a method to avoid such case. You can use String.intern() to force the application to use the same String object whenever possible. For above example, you can change the code to something like this:

public class Reader extends DefaultHandler {

private List<String> listString = new ArrayList<String>();

public void characters(char[] ch, int start, int length) throws SAXException {

String content = new String(ch, start, length).intern();

listString.add(content);

}

}

Now, re-profile the application, force garbage collection, and you will only have one String left in the memory. You can save a lot of memory if you can make sure that there is only one instance of String with certain value in your JVM.

This method also has nice side effect. If you do a lot of String equality comparison in the application, a same String object run faster. To explain this, we can read the source code of String:

public boolean equals(Object anObject) {

if (this == anObject) {

return true;

}

if (anObject instanceof String) {

String anotherString = (String)anObject;

int n = count;

if (n == anotherString.count) {

char v1[] = value;

char v2[] = anotherString.value;

int i = offset;

int j = anotherString.offset;

while (n– != 0) {

if (v1[i++] != v2[j++])

return false;

}

return true;

}

}

return false;

}

If the object is same, then the method will be immediately after this line if (this == anObject). This is very fast and will save a lot of process time if your application do this operations a lot of time.


I heard this chanting many a times, wonder what it means? Is this a Hindi word or a Sanskrit word or a Marathi word? Asked many friends, also called up my Marathi friends in Mumbai but alas, no one actually knew the meaning. So I started googling !!!  🙂

“Ganapati (Sanskrit: gaṇapati), a synonym for Ganesha, is a compound composed of gaṇa, meaning “group”, and pati, meaning “ruler” or “lord”.”

Bappa: father / Lord

“All join in this final procession shouting “Ganapathi Bappa Morya, Purchya Varshi Laukar ya” (O father Ganesha, come again speedily next year). ”

“Morya Gosavi was a 14th century saint of the Ganapatya sect. He was a great devotee of Ganesha. He was originally from a village called Shaligram in Karnataka. He built the Mayureshwar temple at Morgaon, near Pune. The starting of the Ashtavinayak pilgrimage is attributed to him. The words Ganapati Bappa Morya are attributed to him. He was a contemporary of Chattrapati Shahu Maharaj and Peshwa Balaji Vishwanath Bhatt. He took sanjeevan samadhi at Chinchwad, Pune.”

“Mangalmurti : ‘Man’ means complete and glu-gayate means the one endowing Serenity or purity. That which purifies both internally as well as externally is auspicious (mangal). An image bringing auspiciousness is thus Mangalmurti. In Maharashtra ‘Mangalmurti morya’ is used to proclaim Ganapati’s glory. The word morya in it refers to a famous devotee of Lord Ganesh in the fourteenth century called Morya Gosavi, from Chinchvad, near Pune. This depicts the inseparable relationship between God and a devotee.”

“What is the significance of the term “Ganapati Bappa Morya”?

Devotees chant Ganapati Bappa Morya all the time to sing the praises of Lord Ganesh. But how many of them know what the word Morya signify? The word Morya refers to a famous devotee of Lord Ganesh in the fourteenth century called Morya Gosavi, from Chinchvad, near Pune who invoked the Lord with severe penance.

He attained siddhi (special powers and blessings) at Shree Chintamani and his son built the temple to commemorate the event.It is said that Moryaji also performed penances at Siddhi Vinayak in Ahmedabad and in Moreshwar/Mayureshwar at Moregoan where he also built the temple. Thus this depicts the inseparable relationship between God and his devotee.”

“Many sages like tukaram maharaj and others have endorsed Moraya Gosavi as one who merged with Ganapati.

For rationalists, it will be hard to believe but for devotees, praying to Moraya Gosavi means praying to Lord Ganesh!”

Happy Ganesh Chaturthi to all !!!

Source and further information:

http://en.wikipedia.org/wiki/Ganapati

http://en.wikipedia.org/wiki/Morya_Gosavi

http://www.sanatan.org/en/campaigns/Ganesh/page5.htm

http://nayna.in/blog/divine-grace/faq-on-lord-ganesh-part-2/


It was nice Saturday afternoon we, a group of friends from collage, well established in their careers, were discussing about their lives at a class reunion seating on a green grass cushion of Cubbon Park.  Amit says “Buddy things are bad, too much of work at office…can not give enough time to my family”. Rahaul says “ha ha ha….see that is why I am still so happy no family no tension”. Amit says “huh!!! What crap. I know you spend whole night in office and then next day you call me whether there is any opening in my company.” We started laughing. Amit continues “Buddy it is not the family problem, it is the work, the rat race and running behind money attitude”. Chitra says “Yes I do agree that point. But what shall I do. Now market is bad, it is difficult to get a job so need to listen to my boss. Also my company pay is good how I can leave that”. Later the conversation turned to complaints about stress in their work, lives and relationships. Danny finally breaks the thread and says “yeah yeah…we all are in a ‘chakra buhu’ need to come out of…lets meet Vijay Sir one day and discuss about that”. So we decided to go visit our old university professor, who was always an inspiration to them.

It was nice house inside IISC campus very nice and peaceful place. Offering us hot chocolate, ourprofessor went into the kitchen and returned with a large pot of hot chocolate and an assortment of cups.  Some cups were porcelain, glass, crystal, some plain looking, some expensive, some exquisite. He invited each to help themselves to the hot chocolate.

When they all had a cup of hot chocolate in hand, the professor shared his thoughts.

“Notice that all the nice looking, expensive cups were taken, leaving behind the plain and cheap ones.

While it is normal for you to want only the best for yourselves, that is the source of your problems and stress.”

“The cup that you are drinking from adds nothing to the quality of the hot chocolate. In most cases it is just more expensive and in some cases even hides what we drink. What each of you really wanted was hot chocolate.  You did not want the cup . . . but you consciously went for the best cups. And soon, you began to eye one another’s cups.”

I said in my mind “Common proff, I mean that is what we want. We struggled so much to get a nice comfortable life”.

There was streak silence and our beloved professor continues “Now friends, please consider this . . .Life is the hot chocolate . . . your job, money and position in society are the cups. They are just tools to hold and contain life.”

“The cup you have does not define, nor does it change, the quality of life you are living. Sometimes, by concentrating only on the cup, we fail to enjoy the hot chocolate God has provided us. Always remember this . . . . . . . God brews the hot chocolate, He does not choose the cup.”

He looked at me with a wink in his eye, “ya I know you do not believe in God….so for you it is the destiny”.

He continues, “The happiest people don’t have the best of everything. They just make the best of everything that they have!!”

Danny added “Steve Jobs says …Stay Hugry, Stay Foolish”.

Proff says “yes very true, that is for knowledge not for success”.

He continues, “Live simply …Care deeply…Speak kindly…Love generously…and if you can love generously something the success will come and will knock you door and will bring happiness along. So do not chase the success be the best and try to excel”

We all are dumb stuck. He broke the silence and said loudly “Enjoy your hot chocolate gentlemen!!! Remember, the richest person is not the one who has the most, but the one who needs the least. By the way did you guys watched ‘3 idiots’…..’”


I am in this “Garden City” for last eight years. Quite a long time!!!

The name Bangalore almost becomes the synonym for the IT destination of India. Indeed it is.  But I have never hover around the meaning of the city name, until one fine day I came to know the city, which the whole world knows as Bangalore, has changed it’s name to “Bengaluru”. Quite strange who did the affidavit for it? ϑ Anyway “naam se keya karna hai kaam se dekho”, but it still lingers around my mind why so and what is the meaning of the name? “why so” is too big a question to be asked, I suppose this follows in the footsteps of Bombay renaming itself as Mumbai, and Madras renaming itself to be Chennai.. But let us dig into the meaning of that.

Well, the name Bangalore is actually converted by the English speaking people here from the city’s name in the Kannada language, Bengalūru. The earliest reference to the name “Bengaluru” was found in a ninth century Western Ganga Dynasty stone inscription on a “vīra gallu” (ವೀರ ಗಲ್ಲು) (literally, “hero stone”, a rock edict extolling the virtues of a warrior). In this inscription found in Begur, “Bengaluru” is referred to as a place in which a battle was fought in 890. It states that the place was part of the Ganga Kingdom until 1004 and was known as “Bengaval-uru”, the “City of Guards” in Halegannada.

An apocryphal, though quit popular, says during 11th Century Hoysala king Veera Ballala II, while travelling in the forest for hunting got lost. Thirsty and hungry he found a village and old woman served him boiled beans. The King was so grateful and named the place “benda-kaal-uru” (Kannada: ಬೆಂದಕಾಳೂರು) (literally, “town of boiled beans”), which eventually evolved into “Bengalūru”.

Since the locals don’t speak old Karnataka (halle kanada) any longer, the old pronunciation is just as foreign to them as it would be to me. It’s going to be interesting to wrap my tongue around Bengaluru when it’s so similar to the accustomed Bangalore.

I understand this as the native culture reasserting its true identity. The name “Bangalore” was an anglicization imposed upon them by the British rule. It strikes me how in India the native culture remained strongly enough entrenched that they can reassert the native identity like this.

For example in the U.S. the native culture was basically wiped off the face of the earth and the remnants have little power to do anything. If in today’s time a country did to its native culture what the U.S. government did in the 1800’s there’d be a worldwide hue and cry of genocide. And that says again and again how deeply rooted we Indians are to our native culture. Jai Hind!!!

Hello world!


Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!