Question & Answer
Question
db2fmp (Java) processes are not being reused and accumulating on the system consuming memory.
Cause
Configuration issue
Answer
1. Issue ps -elf | grep db2fmp few times and notice that you have multiple db2fmps that are not being reused. For those db2fmp the TIME value does not change between runs on the ps -elf commands
Process Listing, '/usr/bin/ps -elf'
UID | PID | PPID | SZ | STIME | TIME | CMD |
db2dfenc | 790782 | 508074 | 43876 | 11:56:32 | 0:05 | db2fmp (Java) |
db2dfenc | 901186 | 508074 | 43856 | 11:33:28 | 0:05 | db2fmp (Java) |
db2dfenc | 962598 | 508074 | 41736 | 11:31:14 | 0:05 | db2fmp (Java) |
db2dfenc | 995492 | 508074 | 47268 | 11:36:07 | 0:05 | db2fmp (Java) |
db2dfenc | 1028182 | 508074 | 44200 | 11:37:19 | 0:05 | db2fmp (Java) |
db2dfenc | 1101958 | 508074 | 41888 | 11:34:10 | 0:05 | db2fmp (Java) |
2. Issue db2pd -fmp and check the status flag for those 'stale' db2fmp processes:
FMP Process:...................Threads: FmpPid Bit Flags............Active Pooled Forced...Active 790782 64 0x80000003 0.............0.............0......Yes ================================================ Active Threads: Address FmpPid EduPid ThreadId No active threads. Pooled Threads: Address FmpPid ThreadId No pooled threads. Forced Threads: Address FmpPid ThreadId No forced threads. |
The flag value for each db2fmp is the result of an bitwise OR operation for the following potential values:
Flag | Meaning of the flag value |
0x00000000 | 32 bit not threadsafe db2fmp running in 64 bit platform |
0x00000001 | db2fmp has a JVM |
0x00000002 | db2fmp is threaded |
0x00000004 | db2fmp in use as a federated wrapper |
0x00000008 | db2fmp for health monitor |
0x00000010 | db2fmp is marked for shutdown when numActiveThreads is 0. It will not accept new calls |
0x00000020 | db2fmp marked for cleanup by the db2sysc |
0x00000040 | db2sysc has marked entry for agent cleanup (received SIGCHLD, but > 1 active agent on db2fmp) |
0x00000080 | db2fmp marked for cleanup |
0x00000100 | all ipcs for the process have been removed |
0x00000200 | db2fmp has a CLR |
0x00000400 | debugger JVM |
0x00000800 | termination has been to the fmp, but we haven't removed it from the table. |
0x00001000 | this is an admin cmd fmp |
0x00002000 | this is new fmp which is not ready to be used |
0x80000000 | db2fmp will no longer be allowed to create new threads, either due to an explicit thread limit or reaching an internal resource limit |
The flag value 0x80000003 for our problematic db2fmp process 790782 means:
0x00000001 the db2fmp has a JVM -> used by Java routine
+ 0x00000002 the db2fmp is threaded -> for execution of threadsafe routines
+ 0x80000000 FMP will no longer be allowed to create new threads, either due to an explicit thread limit or reaching an internal resource limit
================================================
=0x80000003
4. Because your db2fmp flagged as 0x8000... you might see in the db2diag.log file:
2010-04-30-11.58.02.929391-240 I2069191A370 LEVEL: Warning
PID : 790782 TID : 1 PROC : db2fmp (Java) 0
INSTANCE: db2d NODE : 000
EDUID : 1 EDUNAME: db2fmp (Java) 0
FUNCTION: DB2 UDB, routine_infrastructure, sqlerMasterThreadListener, probe:300
MESSAGE : Java heap is nearly full; no thread created
5. Issue db2 get dbm cfg and check the value of KEEPFENCED.
In order to resolve the issue with accumulation of db2fmp processes there are few things you have to address:
1) review your java routines and ensure that the code is not heavily depends on Garbage Collection. (e.g. close off the objects manually after they are no longer used rather then rely on JVM to clean them up)
From the setting perspective
2) If you use threadsafe java routines (default), then set keepfenced to yes (even for development environment). In that case we will reuse the same thread and reduce the chance of creating new threads and check the java heap usage.
3) If you declare your routines as not threadsafe then you can set keepfenced to either yes or no. When a routine is in a not threadsafe mode, each routine will run in it's own db2fmp/JVM.
If keepfenced is set to no a new fenced mode process is created and destroyed for each fenced mode invocation. If keepfenced is set to yes the existing db2fmp will be returned to the pool for reuse.
Related Information
Was this topic helpful?
Document Information
Modified date:
16 June 2018
UID
swg21432402