开发者

How do you calculate the size of a datatable object?

In C#, how can you calculate the size of a datatable object in memory?

We're using this to store various data groups, and would like to perform some logging/monitoring to aid in tuning开发者_运维技巧 the system.

However one of the pieces of information we need is the size of the datatable object.

Any ideas?


I just had a conversation with a coworker recently about this subjecy. He stated that DataTables first allocate enough memory for 1 record, once you try to exceed that it allocates enough for 2 records, once you exceed that it doubles the total allocation again... this continues adnauseum.

The best way to figure out the relative amount of memory (in terms of rows) is to estimate your largest expected row count, find the highest power of 2 that corresponds to that number: e.g. 2,4,8,16,32,64,128,...,1048576,...etc.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜