Created 03-12-2025 02:51 AM
The Nifi version I use is 1.23.2. After restarting, memory drops but increases steadily as time goes by.As a result, memory usage reaches 100% day by day.The MonitorMemory output for now is like this:
Jvm memory args is:
# JVM memory settings
java.arg.2=-Xms32G
java.arg.3=-Xmx32G
What is the reason of this situation?Shouldn't memory usage reach a certain level and stop?
Created 03-17-2025 11:51 AM
@hus
Java garbage collection will not kick in until JVM heap usage reaches ~80% usage. So setting up MonitorMemory reporting task to monitor at 1% is just going to be noisy.
Now you are reporting that your NiFi will eventually use the full 32GB of allocated heap memory. This is most commonly related to one of the following:
While Java Garbage Collection will clean-up unused heap memory, it can not clean-up heap that is still in use.
You can startup your NiFi will all components on the canvas stopped by changing the following property in the nifi.properties to false:
nifi.flowcontroller.autoResumeState
This will allow you to see what your heap usage looks like from just loading starting up NiFi without anything running yet. The heap usage would reflect the loading of NiFi (which includes flow.json.gz uncompressed, loading of NIFi nars, and loading of queued FlowFiles). The memory usage should stay relatively flat after all is loaded. Then starts your dataflows one at a time to see how each impacts heap. You could also take java heap sumps to analyze what is using the heap (although 32 GB heap would require at least that much free memory somewhere to look a it, so you may want to decrease your heap allocations while troubleshooting).
Please help our community grow. If you found any of the suggestions/solutions provided helped you with solving your issue or answering your question, please take a moment to login and click "Accept as Solution" on one or more of them that helped.
Thank you,
Matt
Created 03-21-2025 02:57 AM
First of all, thank you for your return @MattWho .
I think the reason is distributedMapCacheServer as you said.Because I use distributedMapCacheServer in my stream.
As far as I know, you need to define distributedMapCacheServer to use the distributedMapCacheService.When I look at the features of the two controller services, there are one parameter that catch my eye.DetectDuplicate processors parameters as I shared in the image.
If the Age Off Duration parameter is set to 30 minutes, doesn't it delete the data stored in the distributedMapCacheService after 30 minutes?If not, is there a way to clean-up the distributedMapCacheService?
Created 03-24-2025 05:47 AM
@hus
There are two controller services you are using for your map cache:
You are using the DetectDuplicate processor to interact with the above Controller services.
While the DetectDuplicate processor has a configurable "Age Off Duration" setting, ONLY cached entries where both the following conditions have been met will have the cache entry removed at that configured age off:
So any cached entires for which a duplicate has not yet been detected, that entry will remain in the cache server until the "Max cache Entries" and "Eviction Strategy" settings result in the entry removal.
So depending on what data you are caching, number set for "max cache Entries", and number of duplicates you detect, your cache server likely continues to grow to max and then eviction starts. If you have a "Persistence Directory" configured, the cached data is also being written to that directory so that it is not lost in the event the NiFi instance or DistributedMapCache server is restarted. This also means hat after a NiFi restart the persisted cache is loaded back into heap memory.
Keep in mind that there are other external cache server options that do have HA, are distributed, and would not consume NiFi's heap or memory on the NiFi host if installed on a different server/host.
Please help our community grow. If you found any of the suggestions/solutions provided helped you with solving your issue or answering your question, please take a moment to login and click "Accept as Solution" on one or more of them that helped.
Thank you,
Matt