Fog Creek Software
Discussion Board




Welcome! and rules

Joel on Software

Safe to cache a DataView?

I can't find any official documentation on this.  Is it safe to cache a DataView?

It seems to work.  You can retrieve the view from cache in a subsequent page load and it still shows the same data.  However, a DataView doesn't contain data.  It references a DataTable, which is not being cached.  So how does this work?

My only guess is that the DataView has a reference to the DataTable, so the garbage collector doesn't clean up the DataTable as long as DataView is cached.  If this is true, is this safe to rely upon?

Stress
Monday, September 29, 2003

Correct -- but the main thing you should be worrying about is updating the data - or rather NOT updating it without using something like lock{...}.

Duncan Smart
Tuesday, September 30, 2003

The only way the the DataTable would be garbage collected with a still-referenced DataView attached would be if they used a WeakReference between the two... but they don't, so the DataTable *won't* mysteriously dissappear.

Duncan Smart
Tuesday, September 30, 2003

*  Recent Topics

*  Fog Creek Home