What is it better ?

Hi All,
I would like to know your option...
What is the better approach between (a) and (b) ?
a)
MyClass t = null;
for (int i;......) {
    t = new MyClass();
}b)
for (int i;......) {
    MyClass t = new MyClass();
}Cheers,
ste

What about memory usage or garbage collector ?
hardly a difference, if any.
In my opinion B (or c) is better from the garbage
collector point of view, not sure about memory
usage.it isn't. At most, and only if we're talking about a method that runs beyond the next garbage collection cycle, a single instance might take one garbage collection cycle longer to become eligable for garbage collection and be collected in the first scenario.
Unless you're talking about objects taking massive amounts of memory per instance that's peanuts.
Of course, the most expensive operation is new
MyClass(), but in B the jvm should create any time a
new variable (i mean a new pointer container); in A
just the same pointer changes value (pointing to the
new object)
If you're so worried about those few theoretical microseconds you might save why not declare every variable as a member of the class so you won't have to declare them every time you pass through that method?
Not saying you should (good design practice says you shouldn't) but given your reasoning that would be the logical choice.
But you can't say what'll happen exactly. The compiler or JVM might well decide to optimise away that declaration.

Similar Messages

  • What is the better way to change name of a site with paths and links?

    Hi!
    i m using dreamweaver cs4 and i have a site already configured on dreamweaver
    i need to change the name of the site and at the same time, every path names and every links
    This site has about 50 pages so i would like to know what is the better steps to do for modified the name of the site unless problem?
    I read the informations about  'manage site' but its not clear for me about links and path names!!
    thank you

    Just use site manager to change the site name. Nothing complicated with that.
    What exactly do you mean by changing path names? Do you want to change the name of folders in the site? If so, just change them within DW and it will prompt if you want to update links.

  • Photoshop on Windows or Mac? What system is better?

    Hi I'm thinking on buying new laptop mostly to create stuff in Photoshop, sometimes After Effects videos and to update my community blog [link removed by moderator]
    My friend is saying that I should buy Mac Book because it will work better and faster etc. even with 8GB of RAM. Is it true? Windows Laptops with 16GB of RAM are much more cheaper than Apple... What will be better for me? Thanks in advance.

    Which Platform is better may change over time.  When Photoshop first started you did not have a choice.  Thomas developed Display for the Mac and demonstrated it to Adobe and Photoshop history began.   That was back around 1990 it was Mac Only I think Adobe began to market a Windows version in 1992.  At the time both platforms were nowhere near as robust as they are today. Mac OS 7 and 9 where  poor and buggy and windows was full of bugs.   Mac were using the Power PC processor and PC lintel 8088 family.   Intel the came out with 386 that gave PC mainframe features and Windoes NT and Windows 2000 were developed  PC were becoming of age.  Steve Jobs returned to Apple and IBM would not produce a power efficient PowerPC for Steve's desired laptop  had also use Unix for his Nextstep adventure and knew its virtues. So in a single step he abandoned Apples's OS and the PowerPC. processor.  So now Apple Mac and IBM compatible PC are using the same hardware Processors.  Both platforms have a robust OS these days both are  preemptive multitasking systems.  Mac OS base design is Unix like.  Unix was developed by AT&T Lucent lab in the 1960 time-frame for the PDP 11. Design to be modular and portable where code would be easy to developed using  simple module using pipe-ing data just flows input to output.  Apple is more controlling then Microsoft IMO neither are open system but Apple seems more closed then Microsoft to me.   This has advantages and disadvantages.  Application operation constrain to work the way Apple dictates users get a more consistent environment but less software and Hardware less upgradable.  Photoshop on both platform run into problem easily seen just read through this forum.  I use windows for I had to at work and a gained a lot of knowledge about windows over the years. I'm not about to change.  I also had to use Apple OS 7 and 9 for a little while.  If you going to use computers you will have to learn quite a bit about the OS installed on it.  All computers need to be maintained and backed up.  If you only going to use one application you may be able to get a turn key system.    Find the best products for the jobs you need to do.   You may find you need more then one machine and OS.

  • What's the better order to install OEM + AS + DB

    Hi everbody.
    What's the better order to install on RHEL4 Update2:
    - Enterprise Manager Control Grid (10gR2)
    - Database (10gR2)
    - Application Server (10gR3)
    And about the $ORACLE_HOME?? How to? Each instalation have a separate $ORACLE_HOME??
    Tks!

    Rafael,
    Save the Grid Control as the last installation. The order of Database and Application Server doesn't matter, however I would personally install the database first.
    Please read all Installation Guides' before starting any installations, and follow all pre-requisites stated for RHEL4.
    The Installation Guide's states that all products must be installed in separate ORACLE_HOME. As a matter of fact, the Oracle Installer doesn't allow installing any of these products into an existing ORACLE_HOME.
    Regards,
    Martin

  • What are the better load/performance testing tools available for Flex Application with BlazeDS RO?

    In my application is designed with Flex3, ActionScript3, BlazeDS Remote Objects.
    Just i tried with OPENSTA but i cant do the dynamic parameterization in their generated scripts because the response of the calls is binary values and also we cant get the response using with SCL language.
    While testing with OPENSTA with HttpService, i can do the dynamic parameterization and got the response.
    can give the information about the below questions
    whether we can do dynamic parameterization with OPENSTA for Flex Remote objects?
    and  what are the better load/performance tools available for Flex Remote Objects?

    Your approach is fine, depending on how many and what type of CFCs you are talking about. If they are "singletons" - that is, only one instance of each CFC is needed to be in memory and can be reused/shared from multiple parts of your application - caching them in the application scope is common.  Just make sure they are thread safe ("var" or local.* all your method variables).
    You might consider taking advantage of a dependency injection framework, such as DI/1 (part of the FW/1 MVC framework), ColdSpring, or WireBox (a module of the ColdBox platform that can be used independently).  They have mechanisms for handling and caching singletons.  Then you wouldn't have to go to the application scope to get your CFC instances.
    -Carl V.

  • How to map journal fields and whats is the better  process type

    /Journal/JournalSuspenseCostCentre     NULL
    /Journal/JournalBalancingCentre     Lookup from Organisation ID
    /Journal/JournalMultiCompany     u2018Nu2019
    /Journal/JournalBatchNumber     NULL
    /Journal/JournalNumTransactions     Total number of /Journal/JournalLine transactions
    /Journal/JournalBaseDRTotal     Sum of /Journal/JournalLine/JournalLineBaseValue u2013 Debit Values only
    /Journal/JournalBaseCRTotal     Sum of /Journal/JournalLine/JournalLineBaseValue u2013 Credit Values only
    How to map journal fields and whats is the better  process type idoc/proxies?please let me know
    Journal Line
    Multiple journal lines per header:
    Schema Element     Data
    /Journal/JournalLine/JournalLineCostCentre     Bank account control Cost Centre
    /Journal/JournalLine/JournalLineAccount     Bank account control Account Code
    /Journal/JournalLine/JournalLineMoneyTotal     Transaction Line Amount
    /Journal/JournalLine/JournalLineVolume     NULL
    /Journal/JournalLine/JournalLineDescription     Payee Name
    /Journal/JournalLine/JournalLineChequeBookReference     NULL
    /Journal/JournalLine/JournalLineMatchField     Cheque Number
    NB Contra accounting entries should be posted to:
    Schema Element     Data
    /Journal/JournalLine/JournalLineCostCentre     Bank account control Cost Centre
    /Journal/JournalLine/JournalLineAccount     Bank account control Account Code
    /Journal/JournalLine/JournalLineMoneyTotal     Transaction Line Amount * -1
    /Journal/JournalLine/JournalLineDescription     Payee Name
    /Journal/JournalLine/JournalLineMatchField     Cheque Number
    /Journal/JournalPeriod     Current General Ledger Period
    /Journal/JournalYear     Current General Ledger Year

    It looks you are new to PI,
    you have to develop scenario end to end, by creating source data type and target data type(if you have XSD's not required),then use Graphical mapping (message mapping) to map source and target structures.
    Search in sdn for one end to end scenario you will understand easily
    Regards,
    Raj

  • What's the better approach?

    Hi, I was just making a program that access a DB through JDBC, and I got myself into this dilemma
    What's the better approach to make a connection to a DB?
    approach #1(use of singleton pattern)
    import java.sql.*;
    public class DBConnection {
        private ResultSet rs;
        private Connection conn;
        private PreparedStatement ps;
        private static boolean singleton = false;
        private DBConnection() throws Exception{
            Class.forName("driverPath").newInstance();
         conn = DriverManager.getConnection("url", "user", "pass");
         singleton = true;
        public static DBConnection getInstance() throws Exception{
            if(singleton)
             return null;
            return new DBConnection();
        protected void finalize() throws Throwable {
            //close the connection and release resources...
            singleton = false;
        //Methods to make DB querys and stuff.     
    }approach #2 (make a connection only when doing querys)
    public class DBConnection {
        private ResultSet rs;
        private Connection conn;
        private PreparedStatement ps;
        public DBConnection() throws Exception {
            Class.forName("driverPath").newInstance();
        //Just some random method to access the DB
        public ArrayList<Row> selectAllFromTable() {
            ArrayList<Row> returnValue = new ArrayList<Row>();
         try {
             conn = DriverManager.getConnection("url", "user", "pass");
             //make querys and fill the arraylist with rows from the table
         } catch(Exception ex) {
             returnValue = null;
             ex.printStackTrace();
         } finally {
             if(ps != null)
                 ps.close();
                if(rs != null)
              rs.close();
             if(conn != null)
              conn.close();
         return returnValue;
    }I know this classes maybe don't even compile and I don't handle the Exceptions, I'm just trying to make a point about how to manage the connection
    So, what it's the better approach in your opinions? #1? #2? neither?

    Hi,
    I'm resurrecting this thread to ask is this approach OK?
    I'm trying to make a single MySql JDBC connection accessible throughout the model.
    I'm planning to use it in a Swing application. Whilst I realise the Swing apps are inherently multi-threaded, everything I plan to do can (I think) be done within the constraint that all access to model happens on the EDT, and the user will just have to wear any unresponsiveness.
    package datatable.utils;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    abstract public class MySqlConnection {
         public static final String URL = "jdbc:mysql://localhost/test";
         public static final String USERNAME = "keith";//case sensitive
         private static final String PASSWORD = "chewie00";//case sensitive
         private static final Connection theConnection;
         static {
              String driverClassName = "com.mysql.jdbc.Driver";
              try {
                   Class.forName(driverClassName);
                   theConnection = DriverManager.getConnection(URL, USERNAME, PASSWORD);
              } catch (Exception e) {
                   throw new DAOException("Failed to register JDBC driver class \""+driverClassName+"\"", e);
         public static Connection get() {
              return(theConnection);
    }Is there a better solution short of c3po? Which I played with, but couldn't work out how to configure.
    Thanx guys (and uj),
    keith.

  • What is a better approach, batch or prepared statement?

    Hi,
    In my application, the user account property will be retrieved from DB and the last login time will be updated after a successful sign on. There are two query statements in this procedure; select and update. What is a better approach in JDBC to deal with the two queries: batch or prepared statement?
    Thanks.

    Hi, Duffy,
    Thanks for your input.
    I would like to use PreparedStatement with batch update. From my reading, however, it is not suitable to use PreparedStatement with batch update. At less, I haven't see a single example on the tutorial or article sections of this site. I am not sure the following is valid or not:
                   stmt = connection.prepareStatement(INSERT_SMT_QUERY_STR);
                   stmt.setLong(1, details.getRegardID());
                   stmt.setLong(2, details.getWriterID());
                   stmt.setInt(3, details.getVisibility());
                   stmt.setString(4, details.getSubject().trim());
                   stmt.setString(5, details.getContent().trim());
    stmt.addBatch() <-- what goes into here?

  • What is difference bet  call transaction and session method in BDC

    hi
    what is difference bet  call transaction and session method in BDC
    thanks.

    Hi,
    Session method.
    1) synchronous processing.
    2) can tranfer large amount of data.
    3) processing is slower.
    4) error log is created
    5) data is not updated until session is processed.
    Call transaction.
    1) asynchronous processing
    2) can transfer small amount of data
    3) processing is faster.
    4) errors need to be handled explicitly
    5) data is updated automatically
    Check these link:
    http://www.sap-img.com/abap/difference-between-batch-input-and-call-transaction-in-bdc.htm
    http://www.sap-img.com/abap/question-about-bdc-program.htm
    http://www.itcserver.com/blog/2006/06/30/batch-input-vs-call-transaction/
    http://www.planetsap.com/bdc_main_page.htm
    call Transaction or session method ?
    Thanks,
    Reward If Helpful.

  • My PowerBook-G4 operating system software - Mac OS X 10.5.8 - does not meet minimum requirements for downloading the latest version of  FireFox ... is there an Update for a newer version of my op.sys. software,  or,  what is a better choice of an Upgrade?

    my PowerBook-G4 operating system software  - Mac OS X 10.5.8 -  does not meet minimum requirements for downloading the latest version of  FireFox ... is there an UpDate  to a newer version of my op.sys. software,  Or,  what is a better choice of an UpGrade to a newer/different op.sys. software ?
    Thanx!

    The best maintained PowerPC browser at the moment is TenFourFox:
    http://www.floodgap.com/software/tenfourfox/
    It is a Mac port of a newer version of FF thatn any PowerPC Mac can support natively. It runs, looks and feel like FF.
    I found some add-ons that helped TFF with speed issues. Pleae see my post in another PPC forum:
    FYI: Speed-up for TenFourFox on PowerPC

  • What would be better a new iPhone 3gs or a used iPhone 4?

    what would be better a new iPhone 3gs or a used iPhone 4? The iphone would be 2yrs old and belonged to my sister. I am weighing my iphone options, help!

    I'm sorry I should have been more specific with the situation. I currently own an iPhone 3gs which is still under warranty, I am going to get a new one because I am having some issues with the phone. However, my sister offered me her old Iphone 4 if i want it. Now I am not sure whether I should take her 2 year old iphone 4 or just keep the 3gs I get from the apple store...???

  • What Blackberry is better to get?

    What is the better Blackberry in anyones opinion and fact? The Curve 8530 or the Curve 8900?
    Please give me Kudos if you feel like I helped you
    Thank you
    cuse165
    Solved!
    Go to Solution.

    you can compare the features of both models here:
    http://na.blackberry.com/eng/devices/compare/product-attr-compare.jsp?products=1528&products=1786
    here is what I think matters:
    8530 is better because:
    CDMA device including 3G
    trackpad instead of trackball
    got media keys on the top
    rubber all around
    better hearing aid support
    8900 is better because:
    GSM/GPRS/EDGE device (works everywhere in the world)
    form factor is more elegant
    camera is 3.2MPix instead of 2MPix
    more Bluetooth profiles accepted
    screen definition is 480x360 instead of tiny 320x240
    battery lasts 20% longer
    The search box on top-right of this page is your true friend, and the public Knowledge Base too:

  • What tariff is better to chose.

    I need that tariff satisfys next parameters:
    Php >= 5,5
    There is has to be:
    MySql,
    Nginx, 
    Access via SSH,
    installed Git,
    Linux.
    What tariff is better to chose that it satisfys these parameters.

    Hi,
    Azure websites supports Php >= 5.5
    You might want to see
    How to configure  PHP in Azure websites
    See
    Create a PHP-MySQL Azure website and deploy using Git
    Also check
    This article that shows about how to create a PHP website in
    Azure Web Sites by using the Azure Management Portal, the
    Azure Command Line Tools for Mac and Linux, or the
    Azure PowerShell cmdlets.
    You may want to see "  Learn when to use Azure Websites, Cloud Services, and Virtual Machines "here
    Please write back in case of any queries.
    Regards,
    Shirisha Paderu

  • What is the better download , software or internet?

    what is the better download, software or internet?

    I wish I understood your question. Software is downloaded from the Internet, so I have no idea what you are asking. You can't download the Internet.

  • HT2822 What is the better Connection on Apple TV v2, Ethernet or Wifi 802.11n???? does not support with ethernet gigabit?

    What is the better Connection on Apple TV v2, Ethernet or Wifi 802.11n????
    Does not support with ethernet gigabit?

    If you have stable wifi with good connectivity it should work fine - in reality many people struggle with wifi.
    I was plagued by interference issues with wifi whenever the microwave was used and would always use ethernet now as my first preference for stability.
    As the house is not wired for ethernet several years ago I tried mains powerline network adapters that are made by many companies.
    I use these from Devolo currently:
    http://www.devolo.co.uk/consumer/81_dlan-500-avmini_starter-kit_product-pictures _8.html?l=en
    They are excellent and you can create a wired network in minutes without running long lengths of cable.
    As with wifi they never achieve the highest rated speeds and are dependent on the wiring quality but are more than adequate for HD streaming to multiple AppleTVs.
    Many other manufacturers produce these eg Belkin, Netgear etc as well as lesser known brands.
    AC

Maybe you are looking for

  • Problem with swap space

    Hi All, Using Oracle 10gR1, Solaris 9. prtconf | grep "Memory size" Memory size: 16384 Megabytesswap space is 16g Pga_aggregate_target = 2G and after checking the v$pga_target_advice, it shows optimal. Currently we have a issue of swap space getting

  • Microsoft office 2004 update

    Hi there, I recently did a software update for my microsoft office 2004 on my laptop but stopped it about a quarter of the way through and now only WORD and POWERPOINT works. The EXCEL logo in the dock now has a question mark over it. Is there a way

  • Screen Exit / Badi for VF01 in ECC 5.0 Version

    Dear experts, I want to add some customized field(Bill of lading date) to the screen of billing header and the field should be displayed in the screens of t-code VF01 and VF02 always. I found that the BAdi: BADI_SD_CUST_HEAD But When I try to  create

  • Gracenote CDDB

    How do I turn off the automatic download of titles from Gracenote?

  • Cash transfer from on cash journal to another

    Dear friends, In my company ,we have maintained 4 cash journals in one company code.sometimes cash transfers have occured from on cash journal to another ,can any body suggest to post this entry in FBCJ