(EDITTED... PLEASE SEE COMMENT FOR UPDATED QUESTION)
I have a couple of java .jars that I am using to control a camera and framegrabber in a test setup. They work correctly in that I can get the data I need, and when I release the relevant java objects (in matlab), the hardware become available for use by other code.
Unfortunately, the largest contiguous memory block available after release drops from ~1300MB before getting the main object instance to ~500MB after releasing the object. If I continue to connect and release, this decreases further (although by a much smaller margin).
Even if I clear all variables (or even explicitly 'clear all' or 'clear classes') the memory remains discontiguous. The only way I know to fix it is to quit/restart matlab, and that isn't a good option, because I want other processing to be automatically performed after data acquisition occurs.
Is there something I could be doing in matlab that would cause this, or is it something I need to take up with the developers of the .jar/.dll files?
Below is a segment of the method-code for the matlab object I am using:
        
        
        
        function obj = Camera(IPAddress) 
            import nca.io.*;
            obj.camobj = CNCACamera(IPAddress);
            if ~obj.camobj.isReady
                error(strcat('Problem connecting to CCU @ ',IPAddress, ': Not Ready'))
            end
            import ksi.jace.AVIO.AVIO;
            import ksi.jace.IAVIO.IAVIOBoard;
            import ksi.jace.IAVIO.IAVIOBoardFactory;
            import ksi.jace.IAVIO.IAVIOInputStream;
            obj.AVIOAInstance = AVIO.getInstance();
            obj.AVIOBBoard = obj.AVIOAInstance.getBoard(0,1);
            obj.AVIOCStream = obj.AVIOBBoard.GetInputStream();
            obj.AVIODSource = obj.AVIOCStream.GetInputStreamSources();
            obj.AVIOCStream.SetInputStreamSource(obj.AVIODSource(3));
            
        end
        
        
        function Release(obj)
            obj.AVIODSource(4).Release();
            obj.AVIODSource(3).Release();
            obj.AVIODSource(2).Release();
            obj.AVIODSource(1).Release();
            obj.AVIOCStream.Release();
            obj.AVIOBBoard.Release();
            obj.AVIOAInstance.destroyBoard(obj.AVIOBBoard);
            obj.camobj.uninit;
            clear obj
        end
Thanks in advance for any/all help.