Hi

I'm using a fieldref to write info into a recordref like this:
For every do a lot of times (130.000) approx.
record.init;
for every field in an array list arrFieldNo
field := record.FIELD(arrFieldNo[i]);
do something.....codecodecode....
record.insert;
The problem is that when the outer loop is from 1..1000 approx.
the
field := record.FIELD(arrFieldNo[i]);
Is quite fast, but after that getting the field reference process-time
increases exponentially???!!!
From 1..1000 records is approx. 10 seconds, but from 1000..1300 it is approx. 20 seconds more.....!!!
Can anyone help me or has the same problem?
Best regards
Henrik Ohm
Comments
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
1) Prior to v3.70, there was a problem with RecordRefs/FieldRefs declared as Globals. Is your 'field' Global or Local?
2) First 1000 records insert at 100recs/sec, next 300 at 10 recs/sec. Is it possible that this is 'normal' in the sense that the first 1000 recs simply fill Commit Cache, but from then on inserts are limited by a disk i/o bottleneck?
3) If the reuse of 'field' is somehow leaking memory, how about trying to CLEAR(field) between each use...
Henrik Ohm
Henrik Ohm
*2 : I have tried using COMMIT (shame on me...) every 500 recs and it doesn't help at all. It only seems (for some weird reason) that the FieldRef is slower to be assigned to a field if the parent recordref is getting bigger.
*3 : sigh... have also tried this
I have also tried
to be sure that the two recordrefs are NOT data-related, because duplicate doesn't make recordref a pointer to recordref2 as if recordref := recordref2 would do.
Henrik Ohm
- Declare an array[bigNumber] of FieldRefs;
- Open the RecordRef;
- For each fieldID in ArrayOfFieldIDs, set FieldRefs to RecordRef.FIELD(fieldID);
- Then, enter your 'for every lots and lots of inputs...' code, but use FieldRef as you walk through the fields of the record...
The idea here is to get the FieldRefs from the RecordRef once, and re-use them every time through the loop, instead of the current pattern that creates/destroys a single fieldref (nRecs x nField times)...I made a new function "fieldref2recordref(...,...)" that
does the sub-assigning of fieldrefs as before. I didn't make use of the
array, just moving the fieldref -> recordref assigning to a new function.!
"This problem exists because of a memory leak in the RecRef/FieldRef definition" - Thomas Brodkorb (m b s o n l i n e . o r g )
Thank you for your suggestions FB! Local variables in local functions is apparently the KEY-issue in Navision for keeping memory etc. low.
Have a nice day
Best regards
Henrik Ohm
Henrik Ohm
Could you explain this a bit more?
Whereever you can: Use local vars. expecially for RecordRef + FieldRef
in this case:
ok?
Henrik Ohm