• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Concurrency API

 
Ranch Hand
Posts: 390
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
During the course of learning the new API; I undestood that the new java.util.CopyOnWriteArrayList creates a new copy of the underlying array for writing thereby disposing off synchronization. My question is how does this affect memory management in a situation where there are many concurrent writes to be done; I guess it is going to create this many copies of the arrays and have them stored in memory; this I think is akin to having too many objects in a servlet session. Please correct me if I am wrong.
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I believe the CopyOnWriteArrayList only makes a copy to avoid stepping on an iterator. And once you make a copy, that iterator is safe from future writes. So the only scenario where lots of copies are made, is when you are getting lots of iterators while making lots of calls to mutable methods.

Henry
 
Anselm Paulinus
Ranch Hand
Posts: 390
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Henry for the response
reply
    Bookmark Topic Watch Topic
  • New Topic