Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nacos-client 2.2.0 客户端内存一直增长。 #13179

Closed
fanzy0 opened this issue Mar 12, 2025 · 4 comments
Closed

nacos-client 2.2.0 客户端内存一直增长。 #13179

fanzy0 opened this issue Mar 12, 2025 · 4 comments

Comments

@fanzy0
Copy link

fanzy0 commented Mar 12, 2025

客户端启动之后,内存一直缓慢增长,使用Eclipse MAT,分析内存信息之后,怀疑是:
Thread Stack

com.alibaba.nacos.client.Worker
at sun.misc.Unsafe.park(ZJ)V (Native Method)
at java.util.concurrent.locks.LockSupport.parkNanos(Ljava/lang/Object;J)V (LockSupport.java:215)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(J)J (AbstractQueuedSynchronizer.java:2078)
at java.util.concurrent.ArrayBlockingQueue.poll(JLjava/util/concurrent/TimeUnit;)Ljava/lang/Object; (ArrayBlockingQueue.java:418)
at com.alibaba.nacos.client.config.impl.ClientWorker$ConfigRpcTransportClient.lambda$startInternal$2()V (ClientWorker.java:700)
at com.alibaba.nacos.client.config.impl.ClientWorker$ConfigRpcTransportClient$$Lambda$178.run()V (Unknown Source)
at java.util.concurrent.Executors$RunnableAdapter.call()Ljava/lang/Object; (Executors.java:511)
at java.util.concurrent.FutureTask.run()V (FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(Ljava/util/concurrent/ScheduledThreadPoolExecutor$ScheduledFutureTask;)V (ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run()V (ScheduledThreadPoolExecutor.java:293)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Ljava/util/concurrent/ThreadPoolExecutor$Worker;)V (ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run()V (ThreadPoolExecutor.java:624)
at java.lang.Thread.run()V (Thread.java:748)

Image
请教下如何解决?

@KomachiSion
Copy link
Collaborator

分析内存增长,是如何分析出一个线程堆栈的?

能否给出过程或者具体哪个对象在增长

@fanzy0
Copy link
Author

fanzy0 commented Mar 12, 2025

分析过程如下:

Image

Image

Image

Image

@DeepMagic1126
Copy link

I did not detect a significant increase in heap memory in 2.2.0 version nacos client . Can you provide a demo to reproduce it ?

@fanzy0
Copy link
Author

fanzy0 commented Mar 13, 2025

感谢各位大佬,分析的思路不对。头一次用mat分析堆。找到原因了,是一个业务线程僵死了(用的Timer.schedule 启动的定时任务,但是启动了两个TimerTask任务,不知道为什么第二个TimerTask任务出初始化的时候是在运行了,运行了一会,线程都没了),所以导致一直没处理缓存中的数据,这个缓存队列一直在增大。新版本刚接入的nacos,就一直从组件方面找原因,差点把锅甩给nacos了 。

@fanzy0 fanzy0 closed this as completed Mar 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants