Memory leak libargus / multimedia api

Hi,

I’m using libargus but after a few frames I get the following error:
NvRmChannelSubmit: NvError_IoctrlFailed with error 22
NvRmPirvFlus: NvRmChannelSubmit failed (err = 196623, SyncPointIdx = XXX, SyncPointValue = 0)

I already found a few topics about the error and memory leaks so I checked my program with valgrind:
==21083== LEAK SUMMARY:
==21083== definitely lost: 16,688 bytes in 18 blocks
==21083== indirectly lost: 59 bytes in 1 blocks
==21083== possibly lost: 6,780 bytes in 56 blocks
==21083== still reachable: 2,227,986 bytes in 17,607 blocks
==21083== of which reachable via heuristic:
==21083== length64 : 6,288 bytes in 105 blocks
==21083== newarray : 2,160 bytes in 55 blocks
==21083== suppressed: 0 bytes in 0 blocks
==21083==
==21083== For counts of detected and suppressed errors, rerun with: -v
==21083== ERROR SUMMARY: 70 errors from 11 contexts (suppressed: 0 from 0)

I used functions from nvbuf_utils.h in the following order:

NvBufferMemMap(m_dmabuf, 0, NvBufferMem_Read, &pdata);
NvBufferMemSyncForCpu(m_dmabuf, 0, &pdata);
NvBufferMemSyncForDevice (m_dmabuf, 0, &pdata);
NvBufferMemUnMap(m_dmabuf, 0, &pdata);

Is this the right usage? Or am I creating a memory leak here?

I found the solution myself.

Before the four funtions I mention in the first message, I use:

int m_dmabuf = iImageNativeBuffer->createNvBuffer(resolution,NvBufferColorFormat_ABGR32, NvBufferLayout_Pitch);

After some searching in the code I found this comment:
* Creates a new NvBuffer, copies the image contents to the new buffer, then
* returns the dmabuf-fd. Ownership of this dmabuf-fd is given to the caller
* and must be destroyed using NvBufferDestroy (see nvbuf_utils.h).

So now I call NvBufferDestroy at the end, and my memoryleak is gone.