Pages

Friday, February 25, 2011

Green Machine: Sucking carbon dioxide out of the air


Power.jpg

(Image: F1 Online/Rex Features)

Think of it as a chemical vacuum cleaner for sucking greenhouse gases out of the air.

Air capture, in which carbon dioxide is removed from the atmosphere, has been touted as a potentially promising way to tackle climate change. That's because unlike carbon capture from power plant flue gases, the technology has the potential to reduce existing CO2 levels, rather than simply slowing the rate of increase.

To demonstrate that the technology works, Christopher Jones at the Georgia Institute of Technology in Atlanta tested a CO2 absorbent based on amines - the chemicals predominantly used in power plant carbon capture trials - on gases with CO2 concentrations similar to those found in ambient air.

He found the material was able to repeatedly extract CO2 from the gas without being degraded, which will be vital if the technology is to be used economically on a wide-scale.

However, unlike the liquid amines typically used in power plant carbon capture, which consume large amounts of energy as they must be heated to very high temperatures to re-release their stored CO2, Jones' team has developed a new class of the material called hyperbranched aminosilica, in which the amine is held on a solid porous silica substrate.

Solid amines release the stored CO2 when heated to just 110 degrees Celsius - much lower than the temperatures required by the water-based liquid amine solutions - reducing the amount of energy required by 75 per cent.

This also means the energy needed could be supplied by widely available sources such as waste heat from industrial plants, says Peter Eisenberger of air capture company Global Thermostat, based in New York. The energy could also be supplied by renewable sources such as solar power, he says. The captured CO2 could then be fed to algae, which absorb the gas to produce biofuel and biochar.

Jones is working with the company to test a pilot air capture plant in Menlo Park, California, which is absorbing 2 tonnes of CO2 from the atmosphere each day. A commercial plant could absorb 1 million tonnes of CO2 per day, says Eisenberger.

Reference From:
http://www.newscientist.com/blogs/onepercent/2011/02/green-machine-sucking-co2-out.html 

Thursday, February 24, 2011



Bird Eye View on Google Android Activations


Do you know how Google Android creates the largest market around the globe? If not then don’t worry because here I share you something which is not knowledgeable but also more classify information regarding Google Android. Here I share you peoples the extravagant informative video of Google Android which shows the high speedy flourish popularity and superior growth of Android since the launch to till now in the form of articulate informative map. The video tells us how Google Android handsets or devices activate over the years and in which continent of world they gain the maximum customers or users. The video shows the exclusive breath taking geographical presentation in the form of extensive mapping. The video also shows the ratio of activation over the periods of Android. Let’s stop talk and see this exclusive informative video now in below:


Reference URL:

Wednesday, February 23, 2011

What is Project Coin


Project Coin

The goal of Project Coin is to determine what set of small language changes should be added to JDK 7. That list is:
  • Strings in switch
  • Binary integral literals and underscores in numeric literals
  • Multi-catch and more precise rethrow
  • Improved type inference for generic instance creation (diamond)
  • try-with-resources statement
  • Simplified varargs method invocation.

Monday, February 21, 2011

Serialization Size of Lists

Hopefully we all have some idea of how the ArrayList and LinkedList are structured internally. The ArrayList holds a pointer to a single Object array, which grows as the number of elements exceed the size of the array. The ArrayList's underlying Object array grows by about 50% whenever we run out of space. The LinkedList has pointers to the link nodes at the front and end of the list. Each link node is an object and has pointers forward and backwards and to the object that is being held in the list. The memory requirements of the LinkedList is about 4x larger than an equivalently sized ArrayList. In addition, the ArrayList allows random access into the middle, whereas the LinkedList has a lookup complexity of O(n).
One of the questions I enjoy asking here is this: Which list uses more bytes when serialized? LinkedList or ArrayList?  Think about this for a bit before reading on, considering the internal structure of each list.



Most programmers guess that the LinkedList would have a larger serialized size than the ArrayList. However, that is never the case:

import java.io.*;
import java.util.*;

public class ListWritingSize {
  public static void main(String[] args) throws IOException {
    test(new LinkedList<String>());
    test(new ArrayList<String>());
  }

  public static void test(List<String> list) throws IOException {
    for (int i = 0; i < 10; i++) {
      list.add("hello world");
    }
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ObjectOutputStream out = new ObjectOutputStream(baos);
    out.writeObject(list);
    out.close();
    System.out.println(list.getClass().getSimpleName() +
        " used " + baos.toByteArray().length + " bytes");
  }
}
When we run this, we see that the LinkedList uses 107 bytes, whilst the ArrayList uses 117 bytes. Instead of just naively writing the contents of the collections to the stream, the lists both contain writeObject() andreadObject() methods. These write the contents of the lists to the stream.

Why the 10 byte difference?

The ArrayList and LinkedList work similarly, in that they write out the number of elements and the actual objects contained in the list. However, ArrayList also writes out the size of the underlying array, used to recreate an identical ArrayList to what was serialized.
This additional int is what makes up the 10 byte difference in the serialization size.
At this point I need to also point out that the String "hello world" is only serialized once, after that only a reference number to the object is written.

What about Vector?

The old Vector class implements serialization in a naive way. They simply do the default serialization, which writes the entire Object[] as-is into the stream. Thus if we insert a bunch of elements into the List, then clear it, the difference between Vector and ArrayList is enormous.

import java.util.*;
import java.io.*;

public class VectorWritingSize {
  public static void main(String[] args) throws IOException {
    test(new LinkedList<String>());
    test(new ArrayList<String>());
    test(new Vector<String>());
  }

  public static void test(List<String> list) throws IOException {
    insertJunk(list);
    for (int i = 0; i < 10; i++) {
      list.add("hello world");
    }
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ObjectOutputStream out = new ObjectOutputStream(baos);
    out.writeObject(list);
    out.close();
    System.out.println(list.getClass().getSimpleName() +
        " used " + baos.toByteArray().length + " bytes");
  }

  private static void insertJunk(List<String> list) {
    for(int i = 0; i<1000 * 1000; i++) {
      list.add("junk");
    }
    list.clear();
  }
}
  
When we run this code, we get the following output:
LinkedList used 107 bytes
    ArrayList used 117 bytes
    Vector used 1310926 bytes
  
Vector can use a staggering amount of bytes when being serialized. The lesson here? Don't ever use Vector as Lists in objects that are Serializable. The potential for disaster is too great.

Tuesday, February 15, 2011

Bangalore: Corruption and the inflation are the major concern for Indian investors, according to a survey done by Value Note revealed. Arun Jethmalani, Managing Director Value Note said that the worries over inflation are still dominant but corruption has emerged as a major issue, and this kept the investors's confidence level low .
Corruption kills the confidence of Indian investors

This survey was conducted in eight cities, Mumbai, Delhi/NCR, Kolkata, Chennai, Ahmedabad, Bengaluru, Pune and Hyderabad. The survey says that corruption has come out as a new confidence killer with 19 percent retail investors, eight percent companies and 16 percent advisors stating that it was the most negative economic indicator in the current scenario. It became the major cause of concern over past four quarters.

The Confidence Index in December 2010 quarter is 146.3 that is 0.9 points higher from September 2010 quarter. The retail ICI stands at the highest points at 159.5 wheras the advisor confidence index and the corporate confidence index comes after ICI at 147.2 and 132.2 respectively

Saturday, February 12, 2011

ஸ்பெக்ட்ரம் - மக்களுக்கு "வடை" போனது எப்படி?



தேசிய அவமானமான ஸ்பெக்ட்ரம் பற்றி நாம் அறிவோம், அதில் ஒண்ணேமுக்கால் லட்சம் கோடி ரூபாய் அளவுக்கெல்லாம் ஊழல் செய்யப்படவேயில்லை என்றெல்லாம் மக்களே பேச ஆரம்பித்துவிட்டனர். ராஜா கைது தான் செய்யப்பட்டாரே தவிர குற்றம் நிரூபிக்கப்படவில்லை, அதுவரை நாங்கள் அவரை அரவணைத்துக் காப்போம் என்கிறார் முதல்வர். இது தினம் ஒரு அறிக்கை வரும் தேர்தல் நேரம்,மக்கள் சிந்திக்க வேண்டிய காலம், அப்படி ஸ்பெக்ட்ரம் ஊழலில் மெய்யாகவே நடந்தது என்ன ?!!! என்பதை துபாயில் பணிபுரியும் சிவக்குமார் என்னும் பொறியாளர் அருமையாக ஆய்வு செய்து எழுதியுள்ளார், இது இப்போது இமெயிலில் வரத்துவங்கிவிட்டது, இனியேனும் நன்கு படித்தவர்கள் அவசியம் சிரமம் பாராமல் சிந்தித்து வாக்களித்து நாட்டைக்காக்கவேண்டும். அவசியம் இதைப்படித்துவிட்டு ஃபேஸ்புக், ஆர்குட், ட்விட்டர் தளங்களில் ஃபார்வர்டும் செய்யவும்.
மக்கள் அனைவரையும் இலவசங்களை மட்டுமே வாங்க தெரிந்த மாக்கான்கள் என்றே நினைத்து விட்டார் நம் முதல்வர். அதற்காகத்தான் தமிழ்நாட்டில் அனைவரும் குழந்தை பெற்றுகொள்கிறார்கள் என்று சொன்னாலும் ஆச்சரிய படுவதற்கு இல்லை. என்னது ஏழைகள் பயன்படுத்தும் அளவிற்கு குறைந்த விலையில் சேவையை கொண்டுவந்தது ராசாவா? மக்களே உண்மையை புரிந்து கொள்ளுங்கள். இந்த புளுகு மூட்டைகளின் பாவத்திற்கு ஆளாகாதீர்கள். விலை குறைந்ததிற்கான காரணத்தை இங்கு குறிப்பிடுகிறேன்.

1999 ஆண்டில் தான் தொலைதொடர்பு உரிமங்கள் வழங்க ஆரம்பிக்கபட்டது. அன்று வெறும் பணம் படைத்தவர்கள் மட்டுமே கைபேசியை பயன்படுத்தினர். எனவே நுகர்வோரின் எண்ணிக்கை மிக குறைவு. சில பல லட்சங்கள் மட்டுமே. தொழில் நுட்பவளமான 1G அல்லது 2G அலைக்கற்றைகள் மிக அதிக அளவில் அரசிடம் கையிருப்பு இருந்துள்ளது. ஆனால் உரிமம் வாங்க உலக அளவிலோ இந்திய அளவிலோ போட்டிகள் இல்லை. விலை கொடுத்து உரிமம் வாங்கியவர்கள் லாபம் பெற நுகர்வோரிடம் நிமிடத்திற்கு அதிக கட்டணம்(In coming and out going ) வசூல் செய்ய கட்டாயம் ஏற்பட்டது. இதில் கவனிக்க வேண்டிய இன்னொரு விஷயம் என்னவென்றால் நாம் தான் வசதி படைத்தவர்களாயிற்றே என்று இஷ்டத்திற்கு பேசி நேரத்தையோ பணத்தையோ அன்றைய வசதி படைத்தவர்கள் விரயம் செய்யவில்லை. குறைவான நேரத்துக்குதான் கைபேசியை பயன்படுத்தினர். 

நுகர்வோரின் எண்ணிக்கை குறைவாக இருந்ததால்தான் அன்று அலைகற்றை உரிமம் பெற அதிக நிறுவனங்கள் முன்வரவில்லை. இதை சரி செய்ய அன்றைய அரசு ஒரு தொலை தொடர்பு புரட்சியை உருவாக்க முயன்றது. விளைவு நாளுக்கு நாள் நுகர்வோரின் எண்ணிக்கை அதிகமானது. இன்றும் அதிகமாகி கொண்டே இருக்கிறது. 2010 நுகர்வோரின் எண்ணிக்கை சுமார் 60 கோடிக்கும் மேல். 2008 இல் 50 கோடிக்கும் மேல். 

இதற்கும் அதிகமான மக்கள் பயன்படுத்தும் அளவுக்கு போதிய அலைகற்றைகள் அரசிடம் இன்றும் உள்ளனர். ஆனால் பயன்படுத்துவோரின் எண்ணிக்கை வெறும் 60 கோடிதான். 122 தகுதி இல்லாத நிறுவனங்களுக்கு உரிமம் வழங்க பட்டுள்ளது. தகுதி என்றால் என்ன? போதிய அனுபவம், வங்கி காசோலை, வங்கி செக்யூரிட்டி டெபொசிட் அது மட்டும் இல்லை வாங்கியவுடன் குறிப்பிட்ட காலத்திற்குள் சேவையை தொடங்க வேண்டும். இந்த குறிப்பை நினைவில் வைத்து கொள்ளுங்கள். பின்னால் உதவும். டாட்டா, ரிலையன்ஸ் போன்ற பெரிய நிறுவனங்களும் உரிமம் வாங்கியுள்ளனர். இதோடு அந்த 122 தகுதி இல்லாத நிறுவனங்களையும் சேர்த்து கொள்ளுங்கள்.

நியாயக் கணக்கு:

இந்தியாவில் 60 கோடி மக்கள் கைபேசி சேவையை பயன்படுத்துவதாக உண்மை தகவல் உள்ளது. எல்லோருக்கும் தெரியும் என்று நினைக்கிறேன். ஒரு நபர் தனது கைபேசியை ஒரு நாளைக்கு சராசரியாக வெறும் 15 நிமிடங்கள் (LOCAL CALLS ONLY) பயன்படுத்துவதாக வைத்துக்கொள்வோம். ஒரு நிமிடத்திற்கு 40 பைசா கட்டணம்.



அப்போது 15x0.40 =6.0 ரூபாய் ஒரு கைபேசியின் மூலம் செலவாகிறது. 60 கோடி கைபேசிகள். 60x6.0 = 360 கோடிகள் ஒரு நாளைக்கு செலவாகிறது. ஒரு மாதத்திற்கு 30x360 = 10,800 கோடிகள். ஒரு வருடத்திற்கு 12x10,800 = 1,29,600 கோடிகள். 2008 இல் 2G ஏலம் விடப்பட்டது. இன்று வரை இரண்டு வருடங்கள் ஆகிறது. அப்போ து குறைந்தபட்ச வருமானம் இன்றுவரை2,59,200 கோடிகள். இது ஒரு நாளைக்கு வெறும் 15 நிமிடங்கள் கைபேசியை பயன்படுத்தினால் இரண்டு வருடத்திற்கு கிடைத்திருக்கும் வருமானம்.

இதோடு SMS, MMS, STD, ISD, சேவை கட்டணம், இணைப்பு கட்டணம்.......இன்னும் என்ன என்னவோ கட்டணங்கள் உள்ளது என்று சொல்கிறார்கள் மற்றும் 15 நிமிடத்திற்கு அதிகமாக பயன்படுத்துவோரின் செலவையும் சேர்த்தால் எத்தனை கோடி கோடிகள் வருமானமாக கிடைக்கும் என்பதை நீங்களே கணக்கிட்டு கொள்ளுங்கள். என்னால் கணக்கிடவே முடியவில்லை. என்னிடம் உள்ள கால்குலேட்டர் மற்றும் கணினி காண்பிப்பது "INFINITIVE". நான் தற்போது இந்தியாவில் இல்லை. இருந்திருந்தால் அனைத்தையும் அலசி ஆராய்ந்து இதைவிட இன்னும் துல்லியமாக நடந்த ஊழலின் அளவை குறிப்பிட்டு இருப்பேன். இந்த வருமானம் அனைத்தும் அரசுக்கு கிடைத்திருக்க வேண்டும். அது மக்களை சென்று அடைந்து இருக்கவேண்டும். கிடைத்ததா?

மக்களை சென்றடைந்ததா? நிச்சயம் இல்லை என்றுதான் ஒவ்வொரு மக்களும் கூறவேண்டும். அப்படி என்றால் இந்த மக்கள் பணம் சட்டத்திற்கு புறம்பாக யாரிடமோ சென்று அடைந்துள்ளது. இந்த ஊழல் பணம் அடுத்த சில ஆண்டுகளில் தனது சொந்தநாட்டு மக்களையே தாக்கப்போகிறது. விலைவாசி உயரும். பொருளாதாரம் நாசாகும். "Above middle Class" மக்கள் நடுத்தர மக்களாகவும், நடுத்தர மக்கள் ஏழைகளாகவும், ஏழை மக்கள் மேலும் பரம ஏழைகளாகவும் மாறுவார்கள். 

ஜனநாயகம் வேரோடு அழியும். மனிதாபிமானம், மனிதநேயம் மண்ணோடு மண்ணாகும். ரௌடிசம்,குற்றசம்பவங்கள் தலைவிரித்து ஆடும். கடந்த ஐந்தாண்டுகளாக ஆயுள் கைதியாக உள்ள நடுநிலை பத்திரிகைகள் இனி மரண தண்டனை கைதிகளாக மாற்றப்பட்டு தூக்கில் போடப்படும்.

துரோகம்-1: உரிமம் வாங்கிய அனைத்து நிறுவனங்களும் சுமார் 13000 கோடிக்கும் அதிகம் பொறுமானம் உள்ள(உதாரணம் S .TEL நிறுவனம்13000 கோடிக்கு வாங்க முன்வந்தது) அலைகற்றைகள் உரிமத்தை அடிமாட்டு விலைக்கு அதாவது 1200 , 1300 ,1650 கோடிகளுக்கு திட்டமிட்டு விற்கப்பட்டுள்ளது. அரசுக்கு சேரவேண்டிய, மக்களுக்கு சேர வேண்டிய வருவாய் சில சுய நலவாதிகளை சென்றடைந்துள்ளது.

துரோகம்-2: பெரும்பாலான நிறுவனங்கள் தங்கள் உரிமத்தின் பங்குகளை வெளி நாட்டு நிறுவனங்களுக்கு விற்று கொள்ளை லாபம் பார்த்துள்ளனர். இதனால் அரசுக்கு அதாவது பல கோடி மக்களுக்கு கிடைக்க வேண்டிய அரசின் வருவாய் சில சுய நல தனி மனிதர்களை சென்று அடைந்துள்ளது.

துரோகம்-3: தகுதி இல்லாமல் உரிமம் வாங்கிய 122 நிறுவங்களில் பெரும்பாலான நிறுவனங்கள் இன்னும் சேவையை தொடங்கவில்லை. இதில் "swan, Unitech" போன்ற லெட்டர் பேட் நிறுவனங்களும் அடங்கும். இந்த நிறுவனகள் ஏன் இன்னும் சேவையை தொடங்கவில்லை என்று உள்ளூர ஆராய்ந்தால் மிக தெளிவாக புரியும். பெரிய நிறுவனங்கள் போட்டி இல்லாமல் தொலைதொடர்பு துறையில் கொள்ளை லாபம் பார்க்க அதாவது கட்டணம் என்ற பெயரில் மக்களின் உழைப்பை சுரண்ட பெரும்பாலான தகுதி இல்லாத பினாமி லெட்டர் பேட் நிறுவனங்கள் இன்னும் சேவையை தொடங்கவில்லை.

இவைகள் சேவையை தொடங்கி இருந்தால் சந்தையில் போட்டி அதிகமாகி கைபேசியில் பேசும் கட்டணம் இப்போது இருப்பதை விட மேலும் குறைந்திருக்கும். ஒரு வேளை இதற்காகத்தான் திட்டமிட்டு "S.TEL போன்ற போட்டி நிறுவனங்களுக்கு உரிமம் வழங்கவில்லை என்ற சந்தேகம் தெளிவாக எழுகிறது.

துரோகம்-4: MTNL BSNL போன்ற அரசு நிறுவனங்களுக்கு அதிக அளவில் அலைகற்றைகளை ஒதுக்கி போதிய ஆப்பெரடர்களை நியமித்து இருந்தால் கைபேசியில் பேசும் கட்டணம் நிமிடத்திற்கு வெறும் ஒரு பைசாவுக்கு வந்திருக்கும். மக்கள் அரசினால் பயன் அடைந்து இருப்பார்கள்.

துரோகம்-5: தகுதி இல்லாமல் உரிமம் வாங்கிய லெட்டர் பேட் நிறுவனங்கள் தனது பங்குகளை பல வெளி நாட்டு நிறுவனங்களுக்கு விற்றுள்ளனர். அதில் பாகிஸ்தான் போன்ற நாடுகளும் அடங்கும். இந்தியாவின் தொலை தொடர்பு துறையை இந்த நாடுகளும் பயன்படுத்துகின்றனர். இது உள்நட்டு மக்களின் பாதுகாப்புக்கு மிக பெரிய அச்சுறுத்தல்.

துரோகம்-6: நீரா ராடியா தொலைபேசி உரையாடல்கள், CAG ,தொலைதொடர்பு சம்பந்தபட்ட, கைபற்றபட்ட ஆவணங்கள், சம்பந்தபட்ட பிரதமர் அலுவலக கடிதங்கள் புறகணிப்பு, சட்ட,நிதி துறை கடிதங்கள் புறகணிப்பு, TRAI பரிதுரைகள் புறகணிப்பு இப்படி கோடி கணக்கில் ஆதாரங்கள், சாட்சிகள். முதலில் வருபவருக்கே முன்னுரிமை என்று முந்தைய ஆட்சியாளர்கள் வகுத்த அடிப்படை கொள்கை கூட பின்பற்றப்படவில்லை. அதிலும் முறைகேடு.

துரோகம்-7: இவ்வளவு குற்றங்கள் செய்தும் சம்பந்தபட்ட குற்றவாளிகள் செய்த தவறை ஒப்பு கொள்ளாமல் நாங்கள் தவறு செய்யவில்லை என்று மக்களிடம் பொய் பிரச்சாரம் செய்வது மக்களுக்கு இழைக்கப்பட்ட ஏழாவது துரோகம். இதன் உச்சகட்டம்தான் 2G யில் ஊழலும் இல்லை நஷ்டமும் இல்லை என்று மத்திய அமைச்சரின் பத்திரிகை பேட்டி. இந்த உலகத்திலே தான் மட்டும்தான் புத்திசாலி வக்கீல் மற்ற அனைவரும் அடி முட்டாள்கள் என்ற ஆணவ நினைப்பு.

துரோகம்-8: நடந்த அனைத்து தேச துரோகங்களும், குற்றங்களும் பொருளாதார மேதை பிரதமருக்கு தெரிந்தே கண்முன்னே நடந்துள்ளது. இருந்தும் பிரதமர் வாய் மூடி மௌனியாக இருப்பது மக்களுக்கு இழைக்கபடும் மகா மகா துரோகம்.

துரோகம்-9: ஸ்பெக்ட்ரம் விவகாரத்தில் முறைகேடாக பெறபட்ட பணங்கள் பெரும்பாலானவை இந்தியாவில் புழக்கத்தில் இல்லாமல் அந்நிய நாடுகளில்,வங்கிகளில் முதலீடு செய்யப்பட்டுள்ளதாக தகவல். இந்த பணம் அரசுக்கு வருவாயாக கிடைத்து இருந்தால் ஏராளமான அரசு கல்லூரிகள், பள்ளிகள், பாலங்கள், மருத்துவமனைகள், தொழிற்சாலைகள் என்று உருவாக்கி அனைவருக்கும் கல்வி,வேலைவாய்ப்பு, அடிப்படை வசதிகள் என்று ஏற்படுத்தி ஏழைகளே இல்லாத நாட்டை உருவாக்கி இருக்கலாம். இலவசங்கள் பெறாத மக்களை கண்டிருக்கலாம்.

துரோகம்-10: ஸ்பெக்ட்ரம் ஊழல் பணத்தை பயன்படுத்தி தலித் பற்றும் பிற இனத்தை சேர்ந்த ஏழை விவசாய மக்களிடம் மிரட்டி விளை நிலங்களை அடிமாட்டு விலைக்கு வாங்கப்பட்டதாக தகவல். இது மக்களுக்கு இழைக்கபட்ட துரோகம் பத்து. ஒரு முறைகேட்டை செய்து அதையே மூலதனமாக வைத்து இன்னொரு முறைகேடு செய்யப்பட்டுள்ளது. ஊழல் செய்வதினால் மக்களுக்கு இழைக்கபடும் துன்பங்களுக்கு இதை விட சிறந்த உதாரணம் வேறென்ன வேண்டும். நண்டு கொழுத்தால் வலையில் தங்காது. இதுதான் ஊழலின் விளைவுகள். இவர்கள் ரத்தம் குடிக்கும் கொசுக்கள் மாதிரி. நம்மிடம் உள்ள ரத்தத்தை உறிஞ்சுவதோடு மட்டும் இல்லை அதோடு சேர்த்து நோய் கிருமிகளையும் நமது ரத்தத்தில் விட்டு செல்கின்றனர்.

இப்படி 2G ஊழலில் மக்களுக்கு இழைக்கபட்ட துரோகங்கள் எண்ணில் அடங்காதது. இந்த ஊழலின் தாக்கம் இதோடு நிற்காது. மக்களைத்தான் சுத்தி சுத்தி அடிக்கும். எப்படி? ஊழல் பணத்தை வைத்து ஏழைகளின் நிலங்கள் அடிமாட்டு விலைக்கு வாங்கப்பட்டு அதை பிளாட் போட்டு அதே மக்களிடம் அதிக விலை வைத்து விற்கப்படுகிறது.

ஒரு ஏக்கரை குறைந்த விலைக்கு விற்ற மக்கள் அந்த பணத்தை வைத்து அதே இடத்தில் அதாவது முந்தைய சொந்த இடத்தில ஒரு கிரௌண்ட் நிலம் கூட வாங்க முடியவில்லை. இதுதான் ஊழலின் விளைவு. இப்போது புரிந்து இருக்கும் ஏழைகள் எப்படி உருவாகிறார்கள் என்று. இது மட்டும் இல்லை ஊழல் பணத்தை வைத்து அனைத்து இடங்களையும் வளைத்து போட்டு ரியல் எஸ்டேட் நடத்தும் அனைத்து அரசியல்வாதிகளும் இப்படி ஊழல் பணத்தில்தான் செய்கின்றனர்.

அவர்கள் சொல்வதுதான் விலை. விலைவாசி உயர்வது இயற்கை அல்ல. அனைத்தும் மிக மிக செயற்கையே. இயற்கை என்று ஆளும் கட்சியினர் கூறுவது தவறு. உண்மையை மூடி மறைக்கும் செயல். இது ரியல் எஸ்டேட் மட்டும் இல்லை. அனைத்து பொருள்களுக்கும் பொருந்தும். குறைந்த விகிதத்தில் உள்ள பணக்காரர்கள் மேலும் பணக்காரர்கள் ஆவார்கள். அதிக விகித்தில் உள்ள நடுத்தர மக்கள், ஏழைகள் மேலும் ஏழைகளாக ஆவார்கள். இந்த ஏழை, பணக்காரன் இடை வெளியை குறைக்கத்தான் அரசாங்கம் ஒன்றை மக்கள் தேர்ந்தெடுக்கிறார்கள்.

இன்று ஆளும் வர்க்கத்தினரே அதற்கு முழு முதல் காரணமாக திகழ்கிறார்கள். சொல்லபோனால் அரசின் கடமைகளை அரசியல்வாதிகளும் மறந்துவிட்டனர். இவர்களை தேர்ந்தெடுக்கும் மக்களும் தங்கள் கடமைகளை மறந்து இலவசத்துக்கு பின் செல்கின்றனர். இலவசம் வாங்கும் மக்களே ஒன்றை நன்றாக தெரிந்து கொள்ளுங்கள்.

உங்கள் உழைப்பு என்னும் மூலதனத்தை மறந்து இலவசம் வாங்குவதால் எத்தனை தலைமுறைகள் கடந்தாலும் நீங்கள் ஏழைகளாகத்தான் இருக்க முடியும். உங்கள் வாழ்கை தரமும் உயரபோவதில்லை. இலவசம் கொடுக்க தேவையான வரிபணத்தை செலுத்தும் உழைக்கும் மக்களின் வாழ்கை தரமும் உயரபோவதில்லை. இது நிச்சயம். மாற்றம் ஒன்றே மாறாதது. இலவசம் மாறவில்லை என்றால் உங்கள் வாழ்கை தரமும் மாறபோவதில்லை.

எனது நோக்கமே இந்த 2G உலக மகா ஊழலால் மக்கள் எவ்வாறு வஞ்சிக்கபட்டார்கள் என்பதை ஒவ்வொரு இந்திய குடிமகனும் பத்திரிகை நிறுவனங்களில் பணிபுரியும் நண்பர்கள் உள்பட அனைவரும் தெரிந்து கொள்ளவேண்டும் என்பதுதான். எனவே தெரிந்துகொள்ளுங்கள், புரிந்துகொள்ளுங்கள். ஒவ்வொரு ஏழை மக்களுக்கும் தெரியபடுத்துங்கள். ரோட்டில் இறங்கிதான் போராடவேண்டும் என்று இல்லை.கொடி பிடிக்க அவசியமும் இல்லை. e -mail, FAX , Facebook , orkut என்று எவ்வளவோ தொழில் நுட்ப வசதி உள்ளது. தங்களுக்கு உகந்த ஏதேனும் ஒன்றை தேர்வு செய்து தங்களின் அன்றாட வேலைகள் பாதிக்காத வகையில் சுலபமாக இதை செய்யமுடியும். செய்வீர்கள் என்று நினைக்கிறேன்.

Microsoft India Chairman Ravi Venkatesan quits

NEW DELHI: Software major Microsoft said that Ravi Venkatesan , Chairman and Corporate Vice President of its India operations has resigned.

Venkatesan has decided to pursue opportunities outside Microsoft, Microsoft said in a statement.

A successor will be named in the near future and Venkatesan will partner with Microsoft International President Jean-Philippe Courtois to ensure a smooth transition with his successor, it added.

Microsoft India Chairman Ravi Venkatesan quits

"Ravi came to Microsoft India at a very critical time. He has since architected our growth, making this among the fastest growing markets for us.He has laid a strong foundation which, I believe, will help us to continue our business successes," Courtois said.

Sanket Akerkar will continue to lead overall sales, marketing and services businesses as the Sales and Marketing Head for India, while Hemant Sachdev will continue to lead the Consumer and Online business. 

Friday, February 11, 2011

Memory Usage in Java


In Java, memory is allocated in various places such as the stack, heap, etc. In this newsletter I'm only going to look at objects which are stored on the heap. Please don't take me to task for not mentioning the others, they might appear in a future newsletter.

Say I have a class Foo, how much memory will one instance of that class take? The amount of memory can be determined by looking at the data members of the class and all the superclasses' data members. The algorithm I use works as follows:
  1. The class takes up at least 8 bytes. So, if you say new Object(); you will allocate 8 bytes on the heap.
  2. Each data member takes up 4 bytes, except for long and double which take up 8 bytes. Even if the data member is a byte, it will still take up 4 bytes! In addition, the amount of memory used is increased in 8 byte blocks. So, if you have a class that contains one byte it will take up 8 bytes for the class and 8 bytes for the data, totalling 16 bytes (groan!).
  3. Arrays are a bit more clever, at least smaller primitives get packed. I'll deal with these later.
In order to be able to test many different types of objects, I have written a MemoryTestBench class that takes an ObjectFactory which is able to create the type of object that you want to test. The MemoryTestBench can either tell you how many bytes are used by that object or it can print out a nicely formatted result for you. You get the most accurate results if you make sure that supplementary memory is already allocated when you start counting. I therefore construct the object, call the methods for finding the memory, and then set the handle to null again. The garbage collector is then called many times, which should free up all unused memory. The memory is then counted, the object created, garbage collected, and the memory counted again. The difference is the amount of memory used by your object, voila!
public class MemoryTestBench {
  public long calculateMemoryUsage(ObjectFactory factory) {
    Object handle = factory.makeObject();
    long mem0 = Runtime.getRuntime().totalMemory() -
      Runtime.getRuntime().freeMemory();
    long mem1 = Runtime.getRuntime().totalMemory() -
      Runtime.getRuntime().freeMemory();
    handle = null;
    System.gc(); System.gc(); System.gc(); System.gc();
    System.gc(); System.gc(); System.gc(); System.gc();
    System.gc(); System.gc(); System.gc(); System.gc();
    System.gc(); System.gc(); System.gc(); System.gc();
    mem0 = Runtime.getRuntime().totalMemory() -
      Runtime.getRuntime().freeMemory();
    handle = factory.makeObject();
    System.gc(); System.gc(); System.gc(); System.gc();
    System.gc(); System.gc(); System.gc(); System.gc();
    System.gc(); System.gc(); System.gc(); System.gc();
    System.gc(); System.gc(); System.gc(); System.gc();
    mem1 = Runtime.getRuntime().totalMemory() -
      Runtime.getRuntime().freeMemory();
    return mem1 - mem0;
  }
  public void showMemoryUsage(ObjectFactory factory) {
    long mem = calculateMemoryUsage(factory);
    System.out.println(
      factory.getClass().getName() + " produced " +
      factory.makeObject().getClass().getName() +
      " which took " + mem + " bytes");
  }
}
The ObjectFactory interface looks like this:
public interface ObjectFactory {
  public Object makeObject();
}

Basic Objects

Let's start with the easiest case, a BasicObjectFactory that simply returns a new instance of Object.
public class BasicObjectFactory implements ObjectFactory {
  public Object makeObject() {
    return new Object();
  }
}
When we run this, we get the following output:
BasicObjectFactory produced java.lang.Object which took 8 bytes

Bytes

I suggested earlier that bytes are not packed in Java and that memory usage is increased in 8 byte blocks. I have written the ByteFactory and the ThreeByteFactory to demonstrate this:
public class ByteFactory implements ObjectFactory {
  public Object makeObject() {
    return new Byte((byte)33);
  }
}

public class ThreeByteFactory implements ObjectFactory {
  private static class ThreeBytes {
    byte b0, b1, b2;
  }
  public Object makeObject() {
    return new ThreeBytes();
  }
}
When we run these, we get the following output:
ByteFactory produced java.lang.Byte which took 16 bytes
ThreeByteFactory produced ThreeByteFactory$ThreeBytes which took 24 bytes
This is great (not). When I first started using Java I used to spend hours deciding whether a variable should be an int or short or a byte in order to minimize the memory footprint. I was wasting my time. As I said earlier, I don't know if this is only a problem under NT or if it's the same on all platforms. Knowing Java's dream of being equally inefficient on all platforms, I suspect that it would be the same.

Booleans

Let's carry on and look at a smaller unit of information, the boolean. Now a boolean is simply a bit, true or false, yes or no, zero or one. If I have a class that contains 64 booleans, guess how much memory it will take? 8 for the class, and 4 for each of the boolean data members, i.e. 264 bytes!!! Since a boolean is essentially the same as a bit, we could have stored the same information in one long. If you don't believe me, have a look at the following class:
public class SixtyFourBooleanFactory implements ObjectFactory {
  private static class SixtyFourBooleans {
    boolean a0, a1, a2, a3, a4, a5, a6, a7;
    boolean b0, b1, b2, b3, b4, b5, b6, b7;
    boolean c0, c1, c2, c3, c4, c5, c6, c7;
    boolean d0, d1, d2, d3, d4, d5, d6, d7;
    boolean e0, e1, e2, e3, e4, e5, e6, e7;
    boolean f0, f1, f2, f3, f4, f5, f6, f7;
    boolean g0, g1, g2, g3, g4, g5, g6, g7;
    boolean h0, h1, h2, h3, h4, h5, h6, h7;
  }
  public Object makeObject() {
    return new SixtyFourBooleans();
  }
}
When we run this, we get the following output:
SixtyFourBooleanFactory produced SixtyFourBooleanFactory$SixtyFourBooleans
  which took 264 bytes
Admittedly, the example was a little bit contrived, as you would seldom have that many booleans in one class, but I hope you get the idea.
Sun must have realised this problem so they made constants in java.lang.Boolean for TRUE and FALSE that both contain instances of java.lang.Boolean. I think that the constructor for Boolean should have been private to stop people from creating 16 byte objects that are completely unnecessary.

Arrays of Boolean Objects

A Boolean Array takes up 16 bytes plus 4 bytes per position with a minimum of 8 bytes at a time. In addition to that, we obviously have to count the actualy space taken by Boolean objects.
public class BooleanArrayFactory implements ObjectFactory {
  public Object makeObject() {
    Boolean[] objs = new Boolean[1000];
    for (int i=0; i<objs.length; i++)
      objs[i] = new Boolean(true);
    return objs;
  }
}
Try guess how many bytes would be taken up by a Boolean array of size 1000 with Boolean objects stuck in there. Ok, I'll help you: 16 + 4*1000 (for the pointers) + 16*1000 (for the actual Boolean objects) = 20016. Run the code and see if I'm right ;-) If we, instead of making a new Boolean object each time, use the Flyweights provided in Boolean, we'll get to 16 + 4*1000 = 4016 bytes used.
Primitives get packed in arrays, so if you have an array of bytes they will each take up one byte (wow!). The memory usage of course still goes up in 8 byte blocks.
public class PrimitiveByteArrayFactory implements ObjectFactory {
  public Object makeObject() {
    return new byte[1000];
  }
}
When we run this, we get the following output:
PrimitiveByteArrayFactory produced [B which took 1016 bytes

java.lang.String

Strings actually fare quite well since they can be "internalised" meaning that only one instance of the same String is kept. If you, however, construct your String dynamically, it will not be interned and will take up a bit of memory. Inside String we find:
// ...
private char value[];
private int offset;
private int count;
private int hash = 0;
// ...
Say we want to find out how much "Hello World!" would take. We start adding up 8 (for the String class) + 16 (for the char[]) + 12 * 2 (for the characters) + 4 (value) + 4 (offset) + 4 (count) + 4 (hash) = 64 bytes. It's quite difficult to measure this, as we have to make sure the String is not internalized by the JVM. I used the StringBuffer to get this right:
public class StringFactory implements ObjectFactory {
  public Object makeObject() {
    StringBuffer buf = new StringBuffer(12);
    buf.append("Hello ");
    buf.append("World!");
    return buf.toString();
  }
}
When we run this, we get, as expected, the following output:
StringFactory produced java.lang.String which took 64 bytes

java.util.Vector

Now we get to the real challenge: How much does a java.util.Vector use in memory? It's easy to say, now that we have a MemoryTestBench, but it's not so easy to explain. We start by looking inside the java.util.Vector class. Inside we find the following:
// ...
protected Object elementData[];
protected int elementCount;
// ...
Using the knowledge we already have, we decide that the amount of memory used will be 8 (for the class) + 4 (for the pointer to elementData) + 4 (for elementCount). The elementData array will take 16 (for the elementData class and the length) plus 4 * elementData.length. We then follow the hierarchy up and discover the variable intmodCount in the superclass java.util.AbstractList, which will take up the minimum 8 bytes. For a Vector of size 10, we will therefore take up: 8 + 4 + 4 + 16 + 4*10 + 8 = 80 bytes, or simply 40 + 4*10 = 80 bytes, which agrees with our experiment:
public class VectorFactory implements ObjectFactory {
  public Object makeObject() {
    return new java.util.Vector(10);
  }
}
When we run this, we get the following output:
VectorFactory produced java.util.Vector which took 80 bytes
So, what happens when we create a JTable with a DefaultTableModel with 100x100 cells? The DefaultTableModel keeps a Vector of Vectors so this will take 40 + 4*100 + (40 + 4*100) * 100 = 440 + 44000 = 44440 bytes just for the empty table. If we put an Integer in each cell, we will end up with another 100*100*16 = 160'000 bytes used up.

java.util.LinkedList

What's better, a java.util.LinkedList or a java.util.ArrayList? Experienced followers of these newsletters will of course say: "Neither, the CircularArrayList is better" ;-). Let's see what happens when we put 10000 objects into an ArrayList (which uses the same amount of memory as the Vector) vs. a LinkedList. Remember that each Object takes up 8 bytes, so we will subtract 80000 bytes from each answer to get comparable values:
import java.util.*;
public class FullArrayListFactory implements ObjectFactory {
  public Object makeObject() {
    ArrayList result = new ArrayList(10000);
    for (int i=0; i<10000; i++) {
      result.add(new Object());
    }
    return result;
  }
}

import java.util.*;
public class FullLinkedListFactory implements ObjectFactory {
  public Object makeObject() {
    LinkedList result = new LinkedList();
    for (int i=0; i<10000; i++) {
      result.add(new Object());
    }
    return result;
  }
}
When we run this, we get the following output:
FullArrayListFactory produced java.util.ArrayList which took 120040 bytes
FullLinkedListFactory produced java.util.LinkedList which took 320048 bytes
When we subtract 80000 bytes from each, we find that the ArrayList takes up 40040 bytes (as expected) and the LinkedList uses 240048 bytes. How many of us consider issues like this when we code?
We have come to the end of yet another newsletter. I am trying to put newsletters together that will be worthwhile to send out, so as a result they will not always appear every week, unless I feel particularly inspired.