WalkerKnapp / devolay

A Java binding for the Newtek NDI(tm) SDK.
Apache License 2.0
54 stars 17 forks source link

Excessive Memory Usage when compared with Native NDI Applications #9

Closed WalkerKnapp closed 3 years ago

WalkerKnapp commented 4 years ago

I am finding NDI is very demanding of resources, including LAN performance and as a result of your comment about memory problems I thought I'd investigate a little.

I've compared the memory usage of my B4J application, the Studio Monitor from NewTek's NDI tools and the VB WPF Receive Example from NewTek's examples.

Here is what Windows Resource Monitor shows:

At application startup:

image

Consuming 720p 50fps NDI stream:

image

So I can see that the my Java application is consuming many time more memory that the other applications performing the same task. For comparison, if I change the setting of my application from RECEIVE_BANDWIDTH_HIGHEST to RECEIVE_BANDWIDTH_LOWEST, the memory usage drops to around 600,000KB, but then I finish up with 640x360 frame at 25fps.

I'm not sure what can be done, but clearly my application is far less efficient in its memory use than the other applications.

Originally posted by @bdunkleysmith in https://github.com/WalkerKnapp/devolay/issues/8#issuecomment-570408134

bdunkleysmith commented 4 years ago

Firstly thank you for the incredible amount of work you've obviously put in being able to release 1.2.0. To date I've just simplified my video receiving code to take advantage of no longer having to close and reallocate frame buffers. I look forward to being able to utilise the enhancements in regard to receiving audio.

Along with the above coding changes, I have made other changes to my code structure which has reduced memory usage of my app by around 50%.

However I think some of my performance issues are due to system limitations of the (desktop) PC I've been using as the development platform. I ran it on the ASUS "gaming" laptop I usually use with vMix for streaming and suffered none of the video instability seen on my desktop PC. Both have i7 processors, but the desktop only has Intel HD Graphic 530 compared to the NVIDIA GeForce GTX 1070 on the laptop.

We may have to accept that these applications will be as @mporetvivint said "a pretty heavy fella", but I think I've some work to do at my end to make sure my code and resources are appropriate for the task.

Thanks again for your great work.