Memory Leak using UDF

I am facing memory leaks writing/updating using UDF, where as async write/update without UDF works fine. Details are as follows, please revert if you need more information

Write/Update TPS : 100K TPS Java Client version : 4.1.7 Aerospike version : and

function insert_data(rec, BIN_NAME)
   if aerospike:exists(rec) then
        rec[BIN_NAME] = 1
    rec = nil
    BIN_NAME = nil

I am also experience same issue, in my aerospike cluster the memory keeps on increasing slowly and is killed by OOM. This is only happening when i use UDF, i can help with how to reproduce this issue @meher can you please look

Could this be garbage collection backup and not a memory leak?

Could you try backing off of UDF usage for a period of time and see how that affects memory usage?

Hi Kevin Porter,

Thanks for reply. Once we reached aerospike’s allocated memory limit and continued writing further, we could see on aerospike dashboard memory was stable, however machine’s memory was contiguously increasing. After that we stopped our application hitting aerospike and waited to check if memory coming back to expected usage, but it wasn’t.


Hi, so i was experimenting few things, i found that whenever I uncomment line

rec[bin] = val

RES (memory) keeps increasing for the asd process

Steps to Reproduce:

udf file(sample UDF: pyloader.lua):

function insert_data(rec, bin, val)
    rec[bin] = val
    return 0

python code(

from __future__ import print_function
import aerospike
import time

def insertViaLua(keyId):
    key = ('ABCD', 'TEST_PY', keyId)
    client.apply(key, "pyloader", "insert_data", ["", 1])

config = {
  'hosts': [ ('', 3000) ]

if __name__ == '__main__':
        client = aerospike.client(config).connect()
        import sys
        print("failed to connect to the cluster with", config['hosts'])
    while True:

I am running Aerospike inside Docker:

docker run --env="NAMESPACE=sample" --env="REPL_FACTOR=1" --env="DEFAULT_TTL=30d" --env="PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" --env="AEROSPIKE_VERSION=" --volume="/opt/aerospike-test/data:/opt/aerospike/data:rw" --volume="/opt/aerospike-test/conf:/opt/aerospike/etc:rw" --volume="/opt/aerospike/data" -p 3003:3003 -p 3001:3001 -p 3000:3000 -p 3002:3002 --restart=no --detach=true -t aerospike/aerospike-server --config-file /opt/aerospike/etc/aerospike.conf

Namespace Conf:

namespace ABCD {
  data-in-index true
  default-ttl 0
  high-water-disk-pct 90
  high-water-memory-pct 90
  memory-size 524288000
  replication-factor 2
  single-bin true
  stop-writes-pct 95
  storage-engine device {
    data-in-memory true
    device /dev/nvme1n1
    write-block-size 128K

let me know if you need any thing else @kporter

We found a memory leak in UDF executions for single-bin namespaces. This will be fixed in upcoming patches to 4.2.0 and 4.1.0.

@spmahale were your leaks observed on single-bin namespaces?

Yes, Perfect. We saw memory leaks on single bin namespaces. Looking forward to upcoming patches. Thanks Brad :slight_smile:

The single-bin memory leak is fixed as of server versions,, and all 4.3 versions.

1 Like
© 2015 Copyright Aerospike, Inc. | All rights reserved. Creators of the Aerospike Database.