Also I have tried a variety of parallel pool settings and while some seem to crash faster than other, they all still crash.
Parallel pool never releases used memory leading to instability
    16 vues (au cours des 30 derniers jours)
  
       Afficher commentaires plus anciens
    
Running code like:
rxs = rxsite("AntennaHeight",1.5, ...
            "Latitude", 38.9899587, "Longitude", -76.9353889);
for scenario = 1:2
    switch scenario
        % these are not meaningful paths
        case 1
            txPositions = [linspace(38.9857294, 38.9857294, 10000).', linspace(-76.9442905, -76.9407240, 10000).'].';
        case 2
            txPositions = [linspace(38.9895908, 38.9903186, 10000).', linspace(-76.9432997, -76.9446669, 10000).'].';
    end
pm = propagationModel("raytracing");
data = [];
parfor point = 1:size(txPositions,1)
txs = txsite("AntennaHeight", 1.5, ...
            "Latitude", txPositions(1,point), "Longitude", txPositions(2,point), ...
            "TransmitterPower", 10);
rays = raytrace(txs, rxs, pm, "type", "power"); % rays is Na x Ns cell array
if ~isempty(rays{1}) % only ever 1 tx/1 rx
    rayPower = 0;
    % phasor sum of rec'd power
    for rayPath = 1:numel(rays{1})
        pWatts = 10^(-rays{1}(rayPath).PathLoss/10)*10;
        rayPower = rayPower + pWatts*(cos(rays{1}(rayPath).PhaseShift) + 1i*sin(rays{1}(rayPath).PhaseShift));
    end
    % convert to RSS in dBm and resultant signal phase offset
    RSS = 10*log10(abs(rayPower)/.001); % dBm
    phaseOffset = angle(rayPower) ; % rads
    % collate data
    data = [samplePoints(step, 1), samplePoints(step, 2), RSS, phaseOffset];
end
end
close all force % this is an attempt to fix this issue
save("data.mat","data")
clear data
delete(gcp)
end
This code will spawn a transmitter, move it along a path, sample the RSS at a receiver then append that data into a list which gets saved. After that, the parallel pool is reinitialized and the data variable is cleared before starting the next scenario. The delete(gcp) line was from another about a similar issue which I cant find anymore - this helps but doens't solve the problem.
Running this code, I would expect the memory usage to increase during a single scenario (which is what I see), but I would also expect to see memory usage drop considerably between scenarios. However, this code causes the memory usage to steadily increase across scenarios, regardless of if I delete the parallel pool and clear variables. This almost always results in MATLAB either locking up the computer or just crashing outright. 
The issue never occurs on the first (or even the first few) scenario, but will always happen after some number have been run, so I know that the individual scenarios are totally fine.
Am I going about this wrong or is there something I should do to fix this? This issue is present on R2024b on Ubuntu22 and Win10.
2 commentaires
  Walter Roberson
      
      
 le 16 Jan 2025
				    data = [samplePoints(step, 1), samplePoints(step, 2), RSS, phaseOffset];
variable step is not defined at that point, so it is invoking the function step() with no parameters.
Réponse acceptée
Plus de réponses (1)
  Walter Roberson
      
      
 le 16 Jan 2025
                    txPositions = [linspace(38.9857294, 38.9857294, 10000).', linspace(-76.9442905, -76.9407240, 10000).'];
That is 10000 x 2
            txs = txsite("AntennaHeight", 1.5, ...
            "Latitude", txPositions(1,point), "Longitude", txPositions(2,point), ...
            "TransmitterPower", 10);
That tries to access txPositions(1,point) where point is up to 10000. Because txPositions is 10000 x 2, you cannot access txPositions(1,3)
Voir également
Catégories
				En savoir plus sur Wireless Communications dans Help Center et File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

