java.OutOfMemoryException 在 Ignite 中使用连续查询时

java.OutOfMemoryException when using continuous query in Ignite

我正在使用 Ignite.NET 2.8.0.20190421,当我使用 ICache.QueryContinuous 附加连续查询并长时间侦听对象的更改时出现 OutOfMemoryException。

例如:在服务器端,我在缓存中创建单个对象。 然后我启动客户端并开始使用 QueryContinuous 侦听此对象的更改。在我开始经常更改服务器端的对象并在 Java VisualVM 中查找其 JVM 内存消耗后 - 它不断增长直到 OutOfMemoryException。

看起来服务器在其内存中保存了所有变化对象的版本,尽管它们是无用的。

示例:

// Our object to store, make it big to easily reproduce the problem
public sealed class DataItem
{
  public int[] Data { get; private set; } = new int[1000000];
}

// Do on the server's side:
// Start Ignite and create cache
while(true)
{
  DataItem item = new DataItem();
  cache.Put(0, item);
  Thread.Sleep(300);
}

// Do on the client's side:
// Start Ignite in client's mode, request cache and start listening
cache.QueryContinuous(query);

完整 Visual Studio 重现问题的项目:

https://www.dropbox.com/s/aiu3pq0bidkbbif/IgniteListeners.rar?dl=0

步骤:

  1. Start IgniteListeners.exe 使用任何参数启动服务器端,例如,"IgniteListeners.exe s"
  2. 不带参数启动客户端IgniteListeners.exe
  3. 服务器将在一分钟内崩溃,您可以在Java VisualVM 中看到它的JVM 内存在不断增长。

这似乎是一个已知问题。与连续查询中过度使用内存有关,Ignite节点需要在缓冲区中存储最多1000条更新。如果条目很重,可能会导致 OOM。您可以在此处跟踪进度 https://issues.apache.org/jira/browse/IGNITE-11970.