Hi Bharath.

I've checked the sources and looks like method CollectionConfiguration.getOffHeapMaxMemory() is never called, so the only way to restrict queue capacity is to use capacity parameter of ignite.queue().

One can argue about it, but this looks quite natural to restrict queue by elements count instead of memory, however feel free to submit a JIRA ticket if you consider this as a flaw.


On 2021/11/01 22:28:27 Bharath Kumar Suresh wrote:
> Hello,
>
> I'm trying to set a maximum limit on the memory (not in terms of the number
> of elements) of an ignite queue using
> CollectionConfiguration::setOffHeapMaxMemory
> <https://github.com/apache/ignite/blob/5c189a932d53a5c971d859b6ecd1098ad1da831c/modules/core/src/main/java/org/apache/ignite/configuration/CollectionConfiguration.java#L157>.
> The snippet below is how I try to achieve the same:
>
> CollectionConfiguration queueConfiguration = new
> CollectionConfiguration();
>
> queueConfiguration.setOffHeapMaxMemory(DataSize.ofMegabytes(2L).toBytes());
> ignite.queue("test-queue", 0, queueConfiguration);
>
> As seen above, I set the cap parameter to 0 since I want to define the size
> of the queue in terms of actual memory (2MB in the above example) and not
> the number of elements in the queue.
>
> But somehow this setting doesn’t restrict the actual size of the queue.
> What am I missing? Could someone please help?
>
> Thanks,
> Bharath
>

Reply via email to