permaculture playing cards*
The moose likes Performance and the fly likes ArrayList versus plain ol' String[] Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Performance
Bookmark "ArrayList versus plain ol Watch "ArrayList versus plain ol New topic
Author

ArrayList versus plain ol' String[]

Jason Barraclough
Greenhorn

Joined: Aug 19, 2013
Posts: 5
Hiya folks at the ranch.

I have a problem that is baffling me...



firstnameList is an ArrayList<String>() object.
The above serialised array firstNamesArray is read in from a file. It is 105735 elements in size. When I convert it to an ArrayList object, it mysteriously drops down to 87268 strings in the list.

Plenty of JVM memory left over... I can create as many ArrayList objects of this 87268 String capacity but can't seem to create more than that. I need to incorporate up to 1,555,000 Strings in the list.

Any ideas what might be going on here?
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12806
    
    5
Pretty mysterious alright.

Why are you sure the file contains 105735 String objects. What serialized that String[]?

Bill
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4422
    
    8

Just to add to what William said: have you printed out firstNamesArray.length in that code to confirm the length?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: ArrayList versus plain ol' String[]