Thread Subject: An Odd timer error: Error while evaluating TimerFcn for timer 'timer-1'

Subject: An Odd timer error: Error while evaluating TimerFcn for timer 'timer-1'

From: Jun

Date: 22 Jan, 2012 19:36:36

Message: 1 of 5

Dear Matlab Experts:

Very weired error message showed during the execution of timer object.
-------------------------------------------------------------------------
Error while evaluating TimerFcn for timer 'timer-1'
Could not open file.
-------------------------------------------------------------------------
Everything was perfectly fine, for the first 20 times execution of the callback TimerFcn, then suddenly an error poped out as above. What i do not understand is that why there is a limited number of execution for the timer's callback function.

My code structure is shown below-- very simple one
%%%%
     t = timer('Period',5,'busyMode','queue','ExecutionMode','fixedSpacing');
    t.TimerFcn = {@h5_write};

function h5_write(t, TimerFcn)
%%%%
Has anyone experienced a similar problem? I would be really grateful if you could shed some light on this problem.

Jun

Subject: An Odd timer error: Error while evaluating TimerFcn for timer

From: dpb

Date: 22 Jan, 2012 19:54:20

Message: 2 of 5

On 1/22/2012 1:36 PM, Jun wrote:
> Dear Matlab Experts:
> Very weired error message showed during the execution of timer object.
> -------------------------------------------------------------------------
> Error while evaluating TimerFcn for timer 'timer-1' Could not open file.
> -------------------------------------------------------------------------
> Everything was perfectly fine, for the first 20 times execution of the
> callback TimerFcn, then suddenly an error poped out as above. What i do
> not understand is that why there is a limited number of execution for
> the timer's callback function.
> My code structure is shown below-- very simple one
> %%%% t =
> timer('Period',5,'busyMode','queue','ExecutionMode','fixedSpacing');
> t.TimerFcn = {@h5_write};
>
> function h5_write(t, TimerFcn)
> %%%%
...

Doubt it's the timer at all but the callback function apparently is
trying to open a file. I suspect it is running out of available file
handles as did another poster in a loop not long ago altho it's not
possible to tell w/o the actual code for the callback.

--

Subject: An Odd timer error: Error while evaluating TimerFcn for timer

From: Jun

Date: 22 Jan, 2012 23:39:10

Message: 3 of 5

dpb <none@non.net> wrote in message <jfhphb$pv0$1@speranza.aioe.org>...
> On 1/22/2012 1:36 PM, Jun wrote:
> > Dear Matlab Experts:
> > Very weired error message showed during the execution of timer object.
> > -------------------------------------------------------------------------
> > Error while evaluating TimerFcn for timer 'timer-1' Could not open file.
> > -------------------------------------------------------------------------
> > Everything was perfectly fine, for the first 20 times execution of the
> > callback TimerFcn, then suddenly an error poped out as above. What i do
> > not understand is that why there is a limited number of execution for
> > the timer's callback function.
> > My code structure is shown below-- very simple one
> > %%%% t =
> > timer('Period',5,'busyMode','queue','ExecutionMode','fixedSpacing');
> > t.TimerFcn = {@h5_write};
> >
> > function h5_write(t, TimerFcn)
> > %%%%
> ...
>
> Doubt it's the timer at all but the callback function apparently is
> trying to open a file. I suspect it is running out of available file
> handles as did another poster in a loop not long ago altho it's not
> possible to tell w/o the actual code for the callback.
>


I have exactly the same thought. The timer function seems fine. I am indeed handling a large number of files( more than 100,000 image files). For those file, I need to write them onto a single hdf5 dataset and then delete each one of them. Because the images are captured continously, my function has to be executed periodically. However, I did not include any command to reclaim handle space in my code.

I wonder would Matlab pop out a different error message such like 'out of memory' or ' too many files', if this is the case.
  
I had solved the 'heap space' problem. Do you have any suggestion to increase the number of available handles.

Many thanks in advance.

Jun
 

Subject: An Odd timer error: Error while evaluating TimerFcn for timer

From: dpb

Date: 23 Jan, 2012 00:40:31

Message: 4 of 5

On 1/22/2012 5:39 PM, Jun wrote:
...

> function has to be executed periodically. However, I did not include any
> command to reclaim handle space in my code.
> I wonder would Matlab pop out a different error message such like 'out
> of memory' or ' too many files', if this is the case.

It did...it said it couldn't open the file in fopen() call.

> I had solved the 'heap space' problem. Do you have any suggestion to
> increase the number of available handles.

No, no can do.

You have to fclose() the file handle after you're done with it and you
can't have more than roughly 500 (Windows limit of 512/process) at any
one time.

You'll have to reorganize the code to take what you need from a given
file, do something with it, and then close that file before going on to
solve your dilemma.

--

Subject: An Odd timer error: Error while evaluating TimerFcn for timer

From: Steven_Lord

Date: 23 Jan, 2012 14:50:41

Message: 5 of 5



"dpb" <none@non.net> wrote in message news:jfiaa3$2gf$1@speranza.aioe.org...
> On 1/22/2012 5:39 PM, Jun wrote:
> ...
>
>> function has to be executed periodically. However, I did not include any
>> command to reclaim handle space in my code.
>> I wonder would Matlab pop out a different error message such like 'out
>> of memory' or ' too many files', if this is the case.
>
> It did...it said it couldn't open the file in fopen() call.

To the OP: call FOPEN with two outputs (as per the fifth syntax listed in
the documentation for FOPEN.) If the FOPEN call fails (the fid is -1) check
the message output. It comes from the OS and in this type of situation
probably would say something like:

"Too many open files"

http://www.mathworks.com/help/techdoc/ref/fopen.html

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
timer Jun 22 Jan, 2012 14:40:31
callback Jun 22 Jan, 2012 14:40:31
timerfcn Jun 22 Jan, 2012 14:40:31
error Jun 22 Jan, 2012 14:40:31
rssFeed for this Thread

Contact us at files@mathworks.com