locked
Max capacity of Array List. RRS feed

  • Question

  • User-425575111 posted

    1. How many elements an array list can store in VB.NET? 

    2. Upon what factors the stroing capacity of arraylist depends?

    3. What could be the maximum size of an induvidual item in a array list if the item is string type?

    Anybody please inform.

    Friday, July 1, 2011 1:31 PM

Answers

  • User42903263 posted

    The ArrayList has been superseded by List(Of T). I would hazard a guess that the maximum number of elements is 2^31-1. The total size, and the size of inidividual elements, will be limited by the amount of memory available to your program, below 2GB on a 32-bit OS, and likely limited to the swap space available on your disk drive for a 64-bit OS.

    HTH,

    Andrew

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, July 2, 2011 1:14 PM

All replies

  • User-843484705 posted

    In dot net 1 : The default capacity is 16. and 4.0 Capacity is always greater than or equal to Count|

     

    Capacity is always greater than or equal to Count. If Count exceeds Capacity while adding elements, the capacity is automatically increased by reallocating the internal array before copying the old elements and adding the new elements.

    The capacity can be decreased by calling TrimToSize or by setting the Capacity property explicitly. When the value ofCapacity is set explicitly, the internal array is also reallocated to accommodate the specified capacity.

    Retrieving the value of this property is an O(1) operation; setting the property is an O(n) operation, where n is the new capacity.


    check it and find all the queries: http://msdn.microsoft.com/en-us/library/system.collections.arraylist.capacity.aspx 

    Friday, July 1, 2011 1:57 PM
  • User-425575111 posted

    "In dot net 1 : The default capacity is 16. and 4.0 Capacity is always greater than or equal to Count|"

    What is meant by 16? 16 elements or bytes or KB or MB. Please tell. Isn't it matter of cacapcity of RAM?

    Friday, July 1, 2011 5:15 PM
  • User42903263 posted

    The ArrayList has been superseded by List(Of T). I would hazard a guess that the maximum number of elements is 2^31-1. The total size, and the size of inidividual elements, will be limited by the amount of memory available to your program, below 2GB on a 32-bit OS, and likely limited to the swap space available on your disk drive for a 64-bit OS.

    HTH,

    Andrew

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, July 2, 2011 1:14 PM
  • User-425575111 posted

    Thanks Andrew for such a concrete information.

    Saturday, July 2, 2011 1:32 PM