处理内存中数据的最佳实践 [英] Best practice for working with data in memory

查看:104
本文介绍了处理内存中数据的最佳实践的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好



我想知道.net中最佳做法对于以下内容



我目前有一个.net应用程序,我很忙,只是想知道处理数据的最佳做法。



目前在页面加载我有一些数据被加载到数据表中,数据表用作数据网格的数据源。



在网格中有一个链接,用户点击将它们重定向到计算页面,一旦在计算页面上完成,应用程序将重定向到上一页,并通过视图状态中的数据表将计算结果传递回上一页。



这是最好的方法还是有更好的方式处理这个?



我尝试过的方法:



目前我将一个会话变量传递给计算页面,该变量将更新的行保存为uniqueId完成后,我有一个viewstate,它包含一个带有uniqueid的数据表并更新datatable中的字段,并且在重定向上对viewstate数据表执行select操作以查看rowId = uniqueid是否存在数据并更新datagrid中的列有数据

Hi Guys

I would like to know what would be the best practice in .net for the following

I currently have a .net application which i am busy with and just would like to know what would be the best practice of handling the data.

Currently on page load i have some data that gets loaded into a datatable which is used as the datasource for a datagrid.

in the grid there is a link which the user clicks which redirects them to a calculation page and once completed on the calculation page, the application redirects to the previous page and i pass the calculation back to the previous page through a datatable in a viewstate.

Is this the best way or is there a better way of handling this?

What I have tried:

currently i pass a session variable which holds a uniqueId for the row being updated, to the calculation page once the calculation is done i have a viewstate which holds a datatable with the uniqueid and update the fields in the datatable and on redirect do a select on the viewstate datatable to see if the data exists for the rowId = uniqueid and update the columns in the datagrid if there is data

推荐答案

解决方案很好。当加载的数据变大时,内存管理只会出现问题。第一个提示是:当它变得比正常慢时。



如果你想保留内存而不是检查你是不是要复制数据。计算一次并将结果存储在类数据成员中。减少日志和调试输出。



考虑在获取数据后关闭数据库连接。这是一个很好的资源管理。
The solution is fine. Memory managment gets only a problem, when the loaded data gets to big. First hints is: when it gets slower than normal.

If you want to preserve memory than check that you arent copying data around. Compute once and store the results in class data members. Miminize log and debug output.

Consider closing the db-connection after fetching the data. This is good resource managment.


这篇关于处理内存中数据的最佳实践的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆