How many pieces of data can be stored in list in java

 

From a language point of view, java.util.List is an interface with N multiple implementations, the most commonly used are ArrayList and LinkedList and their various inheritance or synchronization implementations (such as Vector/Queue/Stack). Array storage, then the upper limit is Integer.MAX_VALUELinkedList, which is a linked list inside, which is theoretically infinite. In addition, the things in the List are all in memory (of course, you can also implement one on the disk yourself), so you can put as many as you want. Depends on the size and type of things you put in. The size is easy to calculate. If an object is 1K, then 400,000 objects will occupy at least 400M of memory (not counting other occupancy). In terms of virtual machine memory classification, if it is an ordinary object, it generally occupies the heap space. If it is a constant or something similar to String.intern(), it occupies the Permanent Generation. In actual development, the default memory size of the virtual machine varies according to different virtual machine implementations. You can use -Xmx to adjust the maximum heap size when starting the application. For example, adjust the maximum heap size to 2G: java -Xmx2048m cn.gefostudio.App to adjust immortality The maximum size of the band is 1G: java -XX:MaxPermSize=1024m cn.gefostudio.App

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326494359&siteId=291194637