Cost of cuMemAlloc/cuMemFree


are cuMemAlloc/cuMemFree operations one could do for each frame (eg when processing video) or should that be avoided.

My app needs varying amounts of device memory and I am wondering if I should care to code a memory manager to reuse device memory or just allocate and free it for every frame.


It only depend on the duration of the computation you do on each frame. If it’s H264 Motion Estimator on 1280p (Full HD) frames, you could allocate and free memory without any problem.

But if you just do a lightweight filter on 320x240 video or less, it could impact performances negatively!

Anyway, video frames should be the same size on a stream, so why allocate and free memory between each?

Memory alocation and deallocation have fairly big overheads, you’d be much wiser allocating your max size and reusing it in almost every instance.