Subject:
|
Re: File Error - what does it exactly mean?
|
Newsgroups:
|
lugnet.robotics.nxt
|
Date:
|
Fri, 17 Aug 2007 11:33:40 GMT
|
Viewed:
|
24071 times
|
| |
| |
In lugnet.robotics.nxt, John Hansen wrote:
> In lugnet.robotics.nxt, Pavel Petrovic wrote:
> > > a message "File Error!" shown on the LCD for a short moment
> > > and terminated.
> >
> > The error occured when trying to access elements of array
> > outside of the initialized range.
>
> I would guess that 99% of the time that you get a File Error abend in an NXT
> program it is because of trying to access an element beyond the end of the
> array.
But I am getting it when trying to allocate an array that is larger
than the amount of heap available. And it seems there is no way of
checking how much space remains free, so I have no way of preventing
this File Error! from happening if I have a program that needs to
allocate memory during the run without knowing in advance how much it
would be. The only way I see is ardously manually try how much heap
there is on the start and then try to keep track of it somehow by
computing the amounts eaten by dv, etc...?
To conclude: I am missing a system call/macro that can tell me how
much is ok to pass to arrinit for some particular array. Or alternately,
make arrinit not to crash when there is not enough memory, simply return
empty array, and I will check with arrsize whether the allocation worked out.
I.e. arrinit that does not fill the array with some value...
Or even another way: passing some special constant to arrinit would allocate
the largest possible array that can be allocated (ideally after compacting
the memory)
|
|
Message has 1 Reply: | | Re: File Error - what does it exactly mean?
|
| (...) You've got 32k to work with for all variables of all types, including user-defined types and arrays. Every time you manipulate an array you use up more memory due to copying taking place in the VM. If you shared with me some information about (...) (17 years ago, 17-Aug-07, to lugnet.robotics.nxt)
|
Message is in Reply To:
| | Re: File Error - what does it exactly mean?
|
| (...) I would guess that 99% of the time that you get a File Error abend in an NXT program it is because of trying to access an element beyond the end of the array. I'm glad you were able to figure the problem out quickly. It would be nice if the (...) (17 years ago, 5-Aug-07, to lugnet.robotics.nxt)
|
6 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
This Message and its Replies on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
Active threads in NXT programmable brick
|
|
|
|