title: Java queue with memory size limit
body: <p>I have been trying to find a <code>Java</code> queue implementation with a special size limit. In contrast to the usual size parameter that limits the count of objects in the queue, I need to limit the queue's maximum memory usage (in bytes). The queue would be used to hold objects of very different sizes, some huge and some very small. I.e. the queue would hold only small amount of large objects and bigger amount of smaller objects.</p>
  
  <p>Another possibility would be a queue with a size parameter in insert methods. When adding a new element to the queue I could specify how big the object to be added is.</p>
  
  <p>Would anyone know of such <code>Java</code> queue implementation?</p>
  
  <p>Thanks!</p>