|
Re: ArrayList Performance
|
Posted: Apr 2, 2003 4:15 PM
|
|
Arrays memory must be alloacted contiguously. ArrayList uses array of Object class to store all its elements internally. Event though the real elements, which are objects to be stored can be allocated space anywhere on heap the refernces that will refer to all of them must have contiguous memory. As long as OS is able to serve JVM's contiguos (big) memory request fast your application runs fast. Since you are adding and removing elements from arrayList in bulk , there is a lot of array copying going on inside placing frequent memory allocation demands. In fact, the performance of your application depends on many factors beyond your control. Most of them are memory allocation/delocation. If you use linked list then memory allocation will be fast because it doesn't have to be contigous and in bulk.
|
|