"Chains of habit are too light to be felt until they are too heavy to be broken." -Warren Buffett



   
BentUser Updates Feed     


Featured Articles
iPhone 3G Review, Gripes and Praise: Part I
Xbox Live Arcade 2008 Preview: Part I
Resident Evil 5 Preview
Customer Service?
The Fallout from Sony’s E3 Press Conference
Windows XP and Vista b5270 Side-by-Side
DRM Hell
Sharp XR-10X LCD Projector Review
Xbox 360 Launch
Microsoft BOB Review
Logitech V200 Wireless Notebook Mouse
Office 12 Screenshot Gallery
Apple Thinks Same, Goes Intel
Microsoft Windows Vista Build 5231 Indepth Look - Part 2
Why Google is Being Sued by Publishers
Microsoft Windows Vista Build 5231 Indepth Look - Part I
Comprehensive Tablet PC Review with the HP tc1100
Microsoft Virtual Server 2005 Review
IBM / Lenovo ThinkPad T43 Review
Windows OneCare Live Preview
OpenOffice 2.0 Writer Beta Preview
Windows Mobile 5.0 Preview
Battle of the Betas: IE7 vs. Firefox 1.5
Unicomp Customizer 101 Keyboard Review
Dell UltraSharp 24" Widescreen LCD Monitor - 2405FPW Review
Yahoo! Music Engine First Look
TopDesk Review
More
 
  .NET 2.0 vs. Java 1.5 Shootout
  By Andy

  Front > Software
  11/4/2005
  Specifications    Images    

 

Test 2 – Memory Efficiency, Continued

To further experiment with memory efficiency, we expanded the memory test to include an array of classes.  Classes, as you probably know, are the foundation of object oriented programming, and virtually all modern software uses them in some capacity.  As .NET and Java are both heavily object-oriented, the efficiency with which the two platforms can allocate objects is very important.

In this test we allocate and initialize 500,000 objects of type DataTestObject.  DataTestObject encapsulates some data about a fictional bank account.  The class is simple enough that it is easily portable from C# to Java with only slight modification.  We also make use of two system types – strings and times:

public class DataTestObject
{
    public double BankBalance;
    public string BankAccountID;

    public
string CustomerFirstName;
    public string CustomerLastName;

    public
DateTime MostRecentWithdrawal;

    public DataTestObject()
    {
        BankBalance = 0.0;
        BankAccountID = "DHC116A-111908-5";
        CustomerFirstName = "Jon";
        CustomerLastName = "Doe";
        MostRecentWithdrawal = DateTime.Now;
    }

    
public void UpdateBalance(double d)
    {
        BankBalance += d;
    }
}

This class contains two functions, which perform operations on the object, as well as five fields for storing data.  An array of 500,000 of these objects is created and initialized.

Class Memory Usage
Class Memory Usage 

Here we see .NET reversing the memory outlook and besting Java by a solid margin.  This indicates that since .NET treats native types – such as double – as objects, that this incurs additional overhead of some form.  Java, on the other hand, does not treat native types as objects and therefore can save on this overhead.  However, when it comes to real-world object allocation, it appears that .NET is more efficient.




Previous      Next  
[ Test 2, Memory Efficiency ] [ Conclusions ]
 

 

Contact Us        Links:  NLP APIs      




Copyright � 2005 Retro Reviews LLC.  All Rights Reserved.
Technorati Profile