/usr/share/psychtoolbox-3/PsychMatlabTests/fprintfLeak.m is in psychtoolbox-3-common 3.0.9+svn2579.dfsg1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | function fprintfLeak
% Mathworks Case ID: 319124, reported 11/23/99.
%
% FPRINTF leaks memory, as measured by Mac OS TempFreeMem.
%
% "Thank you for reporting this bug. I will let our development team know,
% but at this time development has stopped for the OS9 platform, so no
% patches are expected."
%
% Megean McDuffy
% Technical Support Engineer
% mmcduffy@mathworks.com
fprintf('This program documents a memory leak in FPRINTF. The amount of \n');
fprintf('Temporary Free Memory available through the Mac OS is reduced \n');
fprintf('by each call to FPRINTF, by approximately the length of the formatted string plus 1.\n');
fprintf('The following example prints 9 bytes, 100 times, and loses a total of about 1000 bytes.\n\n');
free0=Bytes;
tempFree0=Bytes('TempFree');
for i=1:100
fprintf('123456789');
end
free=Bytes;
tempFree=Bytes('TempFree');
fprintf('\n\n');
fprintf('Before: %8ld free, %8ld temp free.\n',free0,tempFree0);
fprintf('After: %8ld free, %8ld temp free.\n',free,tempFree);
fprintf('Change: %8ld free, %8ld temp free.\n',free-free0,tempFree-tempFree0);
fprintf('\nThe most likely explanation is that FPRINTF is calling the Mac Toolbox function TempNewHandle()\n');
fprintf('to allocate space for the output string, and failing to call DisposeHandle().\n');
|