Closed JayFoxRox closed 3 years ago
I don't think memory allocation is slow these days, and considering the typical framerates that would be used it's probably fine. I never saw performance issues myself. I agree though, there's no reason to be wasteful.
I never saw performance issues myself
Yes, it's probably not bad here, because it's at most 8 * 1080
(= 64 bit pointers at 1080p = ) bytes on most machines. Even then it's only 3x 4kiB pages of memory.
However, in #16 I just copied the general code-style and it's allocating the entire framebuffer - even if it might still not be perceivable, it's still bad practice. That said, the RGB → UYVY conversion in #16 is much worse for performance.
I don't think memory allocation is slow these days
I have written fair bit of graphics related code where allocations were bottleneck in relatively hot-loops. So best to avoid any potential issue.
This allocation is probably rather slow:
https://github.com/letmaik/pyvirtualcam/blob/44b4184b5cae2edaec45e974babff9ebcf9ff410/pyvirtualcam/native_windows/main.cpp#L22-L25
Instead, it should be allocated once at
start
, then free'd duringstop
.