我有一个。 Net Core 控制台程序作为缓存服务器程序。配置在下面的代码中描述。
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util.xsd">
<bean class="org.apache.ignite.configuration.IgniteConfiguration">
<property name="includeEventTypes">
<list>
<util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_STARTED"/>
<util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_FINISHED"/>
<util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_FINISHED"/>
<util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_FAILED"/>
<util:constant static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_EXPIRED"/>
<util:constant static-field="org.apache.ignite.events.EventType.EVT_CLIENT_NODE_DISCONNECTED"/>
<util:constant static-field="org.apache.ignite.events.EventType.EVT_CLIENT_NODE_RECONNECTED"/>
<util:constant static-field="org.apache.ignite.events.EventType.EVT_NODE_FAILED"/>
</list>
</property>
<property name="discoverySpi">
<bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
<property name="ipFinder">
<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
<property name="addresses">
<list>
<value>127.0.0.1:47500</value>
</list>
</property>
</bean>
</property>
<property name="socketTimeout" value="300" />
<property name="joinTimeout" value="300" />
</bean>
</property>
<property name="dataStorageConfiguration">
<bean class="org.apache.ignite.configuration.DataStorageConfiguration">
<property name="writeThrottlingEnabled" value="true"/>
<!-- Redefining the default region's settings -->
<property name="defaultDataRegionConfiguration">
<bean class="org.apache.ignite.configuration.DataRegionConfiguration">
<property name="name" value="Default_Region"/>
<property name="maxSize" value="#{1L * 1024 * 1024 * 1024}"/>
<property name="persistenceEnabled" value="true"/>
<property name="checkpointPageBufferSize" value="#{8 * 1024 * 1024 * 1024}"/>
</bean>
</property>
<property name="dataRegionConfigurations">
<list>
<bean class="org.apache.ignite.configuration.DataRegionConfiguration">
<property name="name" value="500MB_Region"/>
<property name="initialSize" value="#{100L * 1024 * 1024}"/>
<property name="maxSize" value="#{500L * 1024 * 1024}"/>
<property name="persistenceEnabled" value="true"/>
</bean>
</list>
</property>
<property name="walMode" value="LOG_ONLY"/>
<property name="storagePath" value="/data/local/db" />
<property name="walPath" value="/data/local/db/wal" />
<property name="walArchivePath" value="/data/local/db/wal/archive" />
</bean>
</property>
</bean>
</beans>
public static IgniteConfiguration GetConfiguration(string springConfigUrl, int jvmInitialMemoryMb, int jvmMaxMemoryMb)
{
var igniteHome = IgniteHome.GetIgniteHome();
var workDir = Path.Combine(igniteHome, "work");
return new IgniteConfiguration()
{
BinaryConfiguration = new BinaryConfiguration
{
Serializer = new BinaryReflectiveSerializer
{
ForceTimestamp = true
}
},
SpringConfigUrl = springConfigUrl,
AutoGenerateIgniteInstanceName = true,
JvmInitialMemoryMb = jvmInitialMemoryMb,
JvmMaxMemoryMb = jvmMaxMemoryMb,
LifecycleHandlers = new[] { LifecycleAwareExample },
FailureHandler = new StopNodeFailureHandler(),
ClientFailureDetectionTimeout = TimeSpan.FromSeconds(5),
FailureDetectionTimeout = TimeSpan.FromSeconds(60),
IgniteHome = igniteHome,
WorkDirectory = workDir,
SystemWorkerBlockedTimeout = TimeSpan.FromSeconds(10),
JvmOptions = JvmOpts,
CommunicationSpi = new TcpCommunicationSpi
{
ConnectTimeout = TimeSpan.FromMilliseconds(5000),
MaxConnectTimeout = TimeSpan.FromMilliseconds(10000)
},
};
}
private static readonly IList<string> JvmOpts = Environment.Is64BitProcess
? new List<string>
{
"-XX:+HeapDumpOnOutOfMemoryError",
"-DIGNITE_QUIET=true",
"-Duser.timezone=UTC",
"-Djava.net.preferIPv4Stack=true"
}
: new List<string>
{
"-XX:+HeapDumpOnOutOfMemoryError",
"-DIGNITE_ATOMIC_CACHE_DELETE_HISTORY_SIZE=1000",
"-DIGNITE_QUIET=true",
"-Duser.timezone=UTC",
"-Djava.net.preferIPv4Stack=true"
};
我启动ignite方法和JVM设置
var server = Ignition.Start(GetConfiguration("IgniteConfig\\config.xml", 1024, 2048));
启动服务器程序后,发现自己什么都没做,长时间运行我的程序的内存使用量也在缓慢增长。有没有人见过这种内存增长缓慢而不采取任何措施的情况?或者我还缺少一些配置。
控制台打印部分如下图:
[08:17:16,984][INFO][grid-timeout-worker-#22%ignite-instance-1e46f40f-14be-4af5-a5ea-10ccfc8fbbd7%][IgniteKernal%ignite-instance-1e46f40f-14be-4af5-a5ea-10ccfc8fbbd7]
Metrics for local node (to disable set 'metricsLogFrequency' to 0)
^-- Node [id=cd7d5ca5, name=ignite-instance-1e46f40f-14be-4af5-a5ea-10ccfc8fbbd7, uptime=00:25:00.979]
^-- Cluster [hosts=1, CPUs=6, servers=1, clients=0, topVer=1, minorTopVer=1]
^-- Network [addrs=[127.0.0.1, 192.168.50.135], discoPort=47500, commPort=47100]
^-- CPU [CPUs=6, curLoad=0%, avgLoad=0.02%, GC=0%]
^-- Heap [used=166MB, free=91.87%, comm=1024MB]
^-- Off-heap memory [used=0MB, free=99.99%, allocated=199MB]
^-- Page memory [pages=25]
^-- sysMemPlc region [type=internal, persistence=true, lazyAlloc=false,
... initCfg=40MB, maxCfg=100MB, usedRam=0MB, freeRam=99.99%, allocRam=99MB, allocTotal=0MB]
^-- metastoreMemPlc region [type=internal, persistence=true, lazyAlloc=false,
... initCfg=40MB, maxCfg=100MB, usedRam=0MB, freeRam=99.91%, allocRam=0MB, allocTotal=0MB]
^-- 500MB_Region region [type=user, persistence=true, lazyAlloc=true,
... initCfg=100MB, maxCfg=500MB, usedRam=0MB, freeRam=100%, allocRam=0MB, allocTotal=0MB]
^-- TxLog region [type=internal, persistence=true, lazyAlloc=false,
... initCfg=40MB, maxCfg=100MB, usedRam=0MB, freeRam=100%, allocRam=99MB, allocTotal=0MB]
^-- volatileDsMemPlc region [type=user, persistence=false, lazyAlloc=true,
... initCfg=40MB, maxCfg=100MB, usedRam=0MB, freeRam=100%, allocRam=0MB]
^-- Default_Region region [type=default, persistence=true, lazyAlloc=true,
... initCfg=256MB, maxCfg=1024MB, usedRam=0MB, freeRam=100%, allocRam=0MB, allocTotal=0MB]
^-- Ignite persistence [used=0MB]
^-- Outbound messages queue [size=0]
^-- Public thread pool [active=0, idle=0, qSize=0]
^-- System thread pool [active=0, idle=7, qSize=0]
[08:18:17,018][INFO][grid-timeout-worker-#22%ignite-instance-1e46f40f-14be-4af5-a5ea-10ccfc8fbbd7%][IgniteKernal%ignite-instance-1e46f40f-14be-4af5-a5ea-10ccfc8fbbd7]
Metrics for local node (to disable set 'metricsLogFrequency' to 0)
^-- Node [id=cd7d5ca5, name=ignite-instance-1e46f40f-14be-4af5-a5ea-10ccfc8fbbd7, uptime=00:26:01.019]
^-- Cluster [hosts=1, CPUs=6, servers=1, clients=0, topVer=1, minorTopVer=1]
^-- Network [addrs=[127.0.0.1, 192.168.50.135], discoPort=47500, commPort=47100]
^-- CPU [CPUs=6, curLoad=0%, avgLoad=0.02%, GC=0%]
^-- Heap [used=169MB, free=91.72%, comm=1024MB]
^-- Off-heap memory [used=0MB, free=99.99%, allocated=199MB]
^-- Page memory [pages=25]
^-- sysMemPlc region [type=internal, persistence=true, lazyAlloc=false,
... initCfg=40MB, maxCfg=100MB, usedRam=0MB, freeRam=99.99%, allocRam=99MB, allocTotal=0MB]
^-- metastoreMemPlc region [type=internal, persistence=true, lazyAlloc=false,
... initCfg=40MB, maxCfg=100MB, usedRam=0MB, freeRam=99.91%, allocRam=0MB, allocTotal=0MB]
^-- 500MB_Region region [type=user, persistence=true, lazyAlloc=true,
... initCfg=100MB, maxCfg=500MB, usedRam=0MB, freeRam=100%, allocRam=0MB, allocTotal=0MB]
^-- TxLog region [type=internal, persistence=true, lazyAlloc=false,
... initCfg=40MB, maxCfg=100MB, usedRam=0MB, freeRam=100%, allocRam=99MB, allocTotal=0MB]
^-- volatileDsMemPlc region [type=user, persistence=false, lazyAlloc=true,
... initCfg=40MB, maxCfg=100MB, usedRam=0MB, freeRam=100%, allocRam=0MB]
^-- Default_Region region [type=default, persistence=true, lazyAlloc=true,
... initCfg=256MB, maxCfg=1024MB, usedRam=0MB, freeRam=100%, allocRam=0MB, allocTotal=0MB]
^-- Ignite persistence [used=0MB]
^-- Outbound messages queue [size=0]
^-- Public thread pool [active=0, idle=0, qSize=0]
^-- System thread pool [active=0, idle=7, qSize=0]
[08:19:16,163][INFO][db-checkpoint-thread-#65%ignite-instance-1e46f40f-14be-4af5-a5ea-10ccfc8fbbd7%][Checkpointer] Skipping checkpoint (no pages were modified) [checkpointBeforeLockTime=0ms, checkpointLockWait=0ms, checkpointListenersExecuteTime=0ms, checkpointLockHoldTime=0ms, reason='timeout']
[08:19:17,047][INFO][grid-timeout-worker-#22%ignite-instance-1e46f40f-14be-4af5-a5ea-10ccfc8fbbd7%][IgniteKernal%ignite-instance-1e46f40f-14be-4af5-a5ea-10ccfc8fbbd7]
Metrics for local node (to disable set 'metricsLogFrequency' to 0)
^-- Node [id=cd7d5ca5, name=ignite-instance-1e46f40f-14be-4af5-a5ea-10ccfc8fbbd7, uptime=00:27:01.047]
^-- Cluster [hosts=1, CPUs=6, servers=1, clients=0, topVer=1, minorTopVer=1]
^-- Network [addrs=[127.0.0.1, 192.168.50.135], discoPort=47500, commPort=47100]
^-- CPU [CPUs=6, curLoad=0%, avgLoad=0.02%, GC=0%]
^-- Heap [used=173MB, free=91.53%, comm=1024MB]
^-- Off-heap memory [used=0MB, free=99.99%, allocated=199MB]
^-- Page memory [pages=25]
^-- sysMemPlc region [type=internal, persistence=true, lazyAlloc=false,
... initCfg=40MB, maxCfg=100MB, usedRam=0MB, freeRam=99.99%, allocRam=99MB, allocTotal=0MB]
^-- metastoreMemPlc region [type=internal, persistence=true, lazyAlloc=false,
... initCfg=40MB, maxCfg=100MB, usedRam=0MB, freeRam=99.91%, allocRam=0MB, allocTotal=0MB]
^-- 500MB_Region region [type=user, persistence=true, lazyAlloc=true,
... initCfg=100MB, maxCfg=500MB, usedRam=0MB, freeRam=100%, allocRam=0MB, allocTotal=0MB]
^-- TxLog region [type=internal, persistence=true, lazyAlloc=false,
... initCfg=40MB, maxCfg=100MB, usedRam=0MB, freeRam=100%, allocRam=99MB, allocTotal=0MB]
^-- volatileDsMemPlc region [type=user, persistence=false, lazyAlloc=true,
... initCfg=40MB, maxCfg=100MB, usedRam=0MB, freeRam=100%, allocRam=0MB]
^-- Default_Region region [type=default, persistence=true, lazyAlloc=true,
... initCfg=256MB, maxCfg=1024MB, usedRam=0MB, freeRam=100%, allocRam=0MB, allocTotal=0MB]
^-- Ignite persistence [used=0MB]
^-- Outbound messages queue [size=0]
^-- Public thread pool [active=0, idle=0, qSize=0]
^-- System thread pool [active=0, idle=7, qSize=0]
答案 0 :(得分:0)
任何做任何事情的 Java 应用程序都必然会增加堆的使用,直到启动 Full GC。当前的堆使用量并不是用于确定实际内存使用量是增长还是稳定的信息量度。考虑收集 GC 日志,但您仍需要循环执行几次 Full GC 才能回答该问题。