I build a synchronisation solution wich recognizes every Record Change in defined Tables and exports XML files in a given intervall. The export “Batch” Codeunit uses a lot of local RecordRef, FieldRef and KeyRef variables. The problem is that the Export for big Tables crashes in an “Unexpected Error … do you want to sent the Error Report”. So I tried to put some Commits in the code. The interval between starting and crashing becomes more less but I’m not really satisified. I knew that there was an old Discussion were somebody said that it is better to use global or local RecordRef’s because Navision has some memory lags. Has anybody the link to the Thread or any other tip for using Ref-Variables etc.?
RecRefs really cause a problem due to a memory leak. RecRef variables always should be declared locally in a function as this is the only real way to make Navision clean up the memory properly. Another side effect by defining the RecRefs locally is regarding speed. The system runs much faster, especially when a large number of records has to be scanned and exported. I enclose an example form which causes Navision to crash while using RecRef variables. It could be that you need to click more often than stated in the form.
Attachment: NavisionCrash Form55555.fob ( 2616bytes )