Can using non primitive Integer/ Long datatypes too frequently in the application, hurt the performance?

前端 未结 4 1679
孤街浪徒
孤街浪徒 2021-01-20 11:02

I am using Long/Integer data types very frequently in my application, to build Generic datatypes. I fear that using these wrapper objects instead o

4条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-20 11:46

    If you have many collections, or large collections, you are likely to have performance problems. See http://www.cs.virginia.edu/kim/publicity/pldi09tutorials/memory-efficient-java-tutorial.pdf.

    If you have many collections, or large collections, or many large collections of boxed types (e.g. Integer, Long) there are alternatives: one is the Mahout Collections library, from http://mahout.apache.org. Mahout collections have open hash tables, which address many of the issues in the linked PDF, and collections that store little-i-integers, etc. Another is Trove, if GPL doesn't bother you.

    If you are not sure that your code qualifies as 'many,' 'large', or 'many large', then by all means use a profiler and see what's going on.

提交回复
热议问题