Cake 2.10.6 memory leak after upgrading to PHP 7.1.11

Hi All,

I’m running a legacy Cake 2.10.6 webapp on AWS Elastic Beanstalk using a t2.micro instance. I recently upgraded from PHP 5.6.x to 7.1.x. After upgrading, within 24 hours, I was getting alarms for system memory usage above 90%. It got to 98% the first time it happened before I was able to take action. At that point, I had to rebuild my environment. Attempting to restart the app server just failed. Unfortunately, after the rebuild, memory usage began climbing again. Here is the output from /proc/meminfo after about 18 hours use:

# cat /proc/meminfo
MemTotal:        1017208 kB
MemFree:           79208 kB
MemAvailable:     160684 kB
Buffers:           68816 kB
Cached:           126972 kB
SwapCached:            0 kB
Active:           722740 kB
Inactive:         101060 kB
Active(anon):     634280 kB
Inactive(anon):    15664 kB
Active(file):      88460 kB
Inactive(file):    85396 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:             0 kB
SwapFree:              0 kB
Dirty:                16 kB
Writeback:             0 kB
AnonPages:        628040 kB
Mapped:            71936 kB
Shmem:             21924 kB
Slab:              84252 kB
SReclaimable:      70684 kB
SUnreclaim:        13568 kB
KernelStack:        3164 kB
PageTables:        16036 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:      508604 kB
Committed_AS:    1651516 kB
VmallocTotal:   34359738367 kB
VmallocUsed:           0 kB
VmallocChunk:          0 kB
AnonHugePages:     22528 kB
ShmemHugePages:        0 kB
ShmemPmdMapped:        0 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
DirectMap4k:       12288 kB
DirectMap2M:     1036288 kB

I decided to restart the app server, before letting it go too far, to see what would happen and verify Apache/PHP was the cause. Here’s the output after a restart:

# cat /proc/meminfo
MemTotal:        1017208 kB
MemFree:          628588 kB
MemAvailable:     699560 kB
Buffers:           61900 kB
Cached:           124036 kB
SwapCached:            0 kB
Active:           186476 kB
Inactive:          99068 kB
Active(anon):      99616 kB
Inactive(anon):    20992 kB
Active(file):      86860 kB
Inactive(file):    78076 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:             0 kB
SwapFree:              0 kB
Dirty:               188 kB
Writeback:             0 kB
AnonPages:         99632 kB
Mapped:            71016 kB
Shmem:             21000 kB
Slab:              79788 kB
SReclaimable:      67520 kB
SUnreclaim:        12268 kB
KernelStack:        2780 kB
PageTables:        10660 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:      508604 kB
Committed_AS:     855540 kB
VmallocTotal:   34359738367 kB
VmallocUsed:           0 kB
VmallocChunk:          0 kB
AnonHugePages:     12288 kB
ShmemHugePages:        0 kB
ShmemPmdMapped:        0 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
DirectMap4k:       12288 kB
DirectMap2M:     1036288 kB

Here is a screenshot of top sorted by %MEM, just prior to the restart:

15

I’m not sure what is going on here. This machine has very little load. The entire app fits into the default opcache settings, only using about 25MB of memory with around 200 files cached. But the system memory continually drains away.

Are there any known issues with PHP 7.1.x? I’ve googled around a bit, but haven’t found anything that seems to apply. This app ran perfectly for months at a time under PHP 5.6.x. I would hate to have to revert, but may have to if I can’t figure this out.

Any help would be very much appreciated!