'Out of memory. The likely cause is an infinite recursion within the program.

27 vues (au cours des 30 derniers jours)
Hi all,
I've seen many people reporting the appearance of this error in relation to some functions, and there are many responses on how to fix those functions to avoid infinite recursion. However, in my case, I get this error when I'm trying to use any functions (even those which has been working properly before) and even when trying to open a script or a figure (!). I can't even load the data.
Any idea how I can fix this?
  7 commentaires
Walter Roberson
Walter Roberson le 12 Juin 2019
The problem could be a fileparts.m
Steven Lord
Steven Lord le 12 Juin 2019
It could be a fileparts.m, but the fileparts function included in MATLAB does call isrow as part of its execution.

Connectez-vous pour commenter.

Réponse acceptée

Steven Lord
Steven Lord le 12 Juin 2019
Guillaume is correct. You've written your own isrow.m that shadows the built-in isrow function.
The fileparts function that is part of MATLAB calls isrow as part of its execution. The isrow function that is part of MATLAB (and which fileparts normally calls) is a built-in function, but the error message shows that the error occurs on line 11 of isrow.m which calls fileparts. Calling fileparts calls isrow which calls fileparts which calls isrow .... Many functions (including open) call fileparts and so enter this infinite loop.
Rename or remove the isrow.m file. You may also want to check (using which) if you've shadowed additional built-in functions in the same directory and rename or remove them as well.
  1 commentaire
Magdalena Kachlicka
Magdalena Kachlicka le 12 Juin 2019
Thank you all for your help! I really appreciate it!
There is indeed a function called "inrow.m" in the FieldTrip toolbox folder! I was looking for a problem in Matlab and my own scripts, and it didn't make much sense, but it didn't cross my mind to check the very contents of the downloaded toolboxes I'm using.
This very much explains why the problem was coming back after cleaning cache and adding those folders back to the path. Something must have happened with my folders settings - my default path for FieldTrip should only include selected folders, not all of them, so when I deselected those I'm not using (incl. the one containing this function!), the problem was solved!
Once again big thanks!

Connectez-vous pour commenter.

Plus de réponses (4)

Arhant Jain
Arhant Jain le 29 Août 2020
Inside the eeglab lab folder, just delete the folder associated with fieldtrip box. It will solve your problem.

Deepak Khani
Deepak Khani le 26 Oct 2020
Out of memory. The likely cause is an infinite recursion
within the program.
Error in vdp1 (line 3)
[t,y] = ode45(@vdp1,[0 20],[2; 0]);
  5 commentaires
Walter Roberson
Walter Roberson le 27 Oct 2020
%calls to the function go **before** the function definition
[t,y]=ode45(@vds1,[0 20],[2; 0]);
plot(t,y(:,1),'-o',t,y(:,2),'-o')
title('Solution of viscous damping force with ODE45');
xlabel('Time t');
ylabel('Solution y');
legend('y_1','y_2')
%my1''+cy1'+ky1=0 is the equation of viscous damping Single degree of freedom.
%Rewrite this equation as a system of first order ODEs by making the
%substitution y1'=y2 and m=20kg ,c=10, k=30;
function dydt = vds1(t,y)
c=10;
k=20;
m=20;
dydt=[y(2);-(c*y(2)+k*y(1))/m];
end
This can all go in one file instead of splitting into two files, but if you put it in one file, then the one file cannot be named vds1.m
Deepak Khani
Deepak Khani le 27 Oct 2020
Thank you sir for helping me out, i am just a begineer in matlab.

Connectez-vous pour commenter.


Brianna Biondo
Brianna Biondo le 26 Juil 2021
Out of memory. The likely cause is an infinite recursion
within the program.
Error in odearguments (line 90)
f0 = feval(ode,t0,y0,args{:}); %ODE15I sets args{1} to yp0.
  2 commentaires
Brianna Biondo
Brianna Biondo le 26 Juil 2021
function dNcelldt = intcellstorednitrogen (~, Ncell)
muMax = 0.26;
KN = 0.033;
KS = 0.077;
KiS = 500;
KiX = 152;
YXN = 27;
KiN = 0.073;
N0 = [5;0];
tRange = (0:144);
[~,NSol] = ode45(@nitrogenconsumption,tRange, N0 );
S0 = [100;0];
[~,SSol] = ode45(@glucoseconsumption,tRange, S0 );
Xf0 = [0.2;0];
[~,XfSol] = ode45(@lipidfreecellgrowth,tRange, Xf0 );
for N = 1:numel(NSol); S = 1:numel(SSol) ; Xf = 1:numel(XfSol);
muS = muMax .* (N/(KN +N)) .* (S/(KS+S)) .* (1/(1+(S/KiS))) .* (1/(1+(Xf/KiX)));
muN = muMax .*(1./(1+(N/KiN))) .* (Ncell./((1/(10.*YXN))+Ncell)) .* (S./(KS+S)) .* (1./(1+(S/KS))).* (1./(1+(Xf./KiS)));
dNcelldt = (-(((1/(3.*YXN))-Ncell).*muS)+(((2/(3.*YXN))+Ncell).*muN))*t;
end
end
Steven Lord
Steven Lord le 26 Juil 2021
You call the ode45 function three times in this code. One of those calls (with nitrogenconsumption, glucoseconsumption, or lipidfreecellgrowth as the ODE functions) will eventually have them call ode45 with that function as the ODE function.
So for example if nitrogenconsumption includes a line that says
[~, Nsol] = ode45(@nitrogenconsumption, % some other code
then nitrogenconsumption would call ode45 which would call nitrogenconsumption which would call ode45 which would call nitrogenconsumption which would call ode45 which would call nitrogenconsumption which would call ode45 ... and eventually MATLAB throws this error.
Move the ode45 call outside the function that it will call (that you've specified as the first input argument.)

Connectez-vous pour commenter.


Christine Anne
Christine Anne le 29 Juil 2024
Out of memory. The likely cause is an infinite recursion within the program.
SIRmodel
tRange = [0 14];
Y0 = [999; 1; 0];
[tSol,YSol] = ode45(@SIRmodel,tRange,Y0);

Catégories

En savoir plus sur Programming 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!

Translated by