December 1st, 2004, 9:45 pm
Is that an array of doubles? a 20000x1000 array of doubles will cost you 160MB of ram! the java VM uses only 64M ram by default.How much memory do you have on your system? If the answer is <= 256MB you will probably need to do some optimisation so you don't have to hold such a large array in memory, otherwise try running it with the -Xmx parameter (e.g. -Xmx256M tells the VM to use 256M, see "java -X")> Also, is there a performance penalty of creating say 1000 object that contain only two int values each and then adding them to an arraylist versus having a 2x1000 array with the values?Yes there will be a performance hit when using arraylist, but to hold 1000 object the penalty should be pretty small, so by all means use it if you want to have the extra flexibilities. The use of object instead of primitive types is another overhead, but I would expect the impact to be small if the class just has 2 integer fields.