哪种方式会占用更多内存? [英] Which way will take more memory?

查看:54
本文介绍了哪种方式会占用更多内存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨:


我想在clicnt浏览器的数据库表中显示一组记录。

我有两种方法可以做到这一点(用JScript编写):


1.第一种方式是:


<%

var sql = 从table1中选择firstname;

var obj = new ActiveXObject(" ADODB.Recordset");

obj.open(sql,conn);

while(!obj.EOF)

{

Response.write(obj(" firstname")+"< br>") ;

obj.movenext();

}

obj.close();

%> <第二种方式是:

<%

var arr = new Array();

var sql ="从table1中选择firstname" ;;

var obj = new ActiveXObject(" ADODB.Recordset");

obj.open(sql,conn);

while(!obj.EOF)

{

arr [arr.length] = new String(obj(" firstname"));

obj.movenext();

}

obj.close( );


.......

for(i = 0; i< arr.length; i ++)

{

document.write(arr [i] +"< br>");

}

%>

我认为第二种方式更灵活,但它比第一种方式需要更多的内存,因为数组arr会留下更多的记忆。我是/ b $ b正确吗?您认为第二种方式需要更多服务器资源吗?你有没有更好的想法改善第二种方式?


我尝试第二种方式的原因是我想让我的服务器

辅助程序(大多数用JScript编写)是基于对象的(不是OOP)编程

样式。但我怀疑基于对象的程序将需要更多的内存或服务器资源。


非常感谢你!


Qing

Hi:

I want to show a set of records in the database table on the clicnt browser.
I have two ways to do this (writen in JScript):

1.The first way is:

<%
var sql = "select firstname from table1";
var obj=new ActiveXObject("ADODB.Recordset");
obj.open(sql, conn);
while(!obj.EOF)
{
Response.write(obj("firstname") + "<br>");
obj.movenext();
}
obj.close();
%>
2. The second way is:
<%
var arr=new Array();
var sql = "select firstname from table1";
var obj=new ActiveXObject("ADODB.Recordset");
obj.open(sql, conn);
while(!obj.EOF)
{
arr[arr.length] = new String(obj("firstname"));
obj.movenext();
}
obj.close();

.......
for(i=0;i<arr.length;i++)
{
document.write(arr[i] + "<br>");
}
%>
I think the second way is more flexible but it will take nuch more memory
than the first way, because the array "arr" will take more memory. Am I
correct? Do you think the second way will need more server resources? Do you
have better idea to improve the second way?

The reason that I tried the second way is that I wanted to make my server
side programs (most writen in JScript) be object-based (not OOP) programming
style. But I am doubt that the object-based programs will take much more
memory or server resources.

Thank you very much!

Qing

推荐答案

我不知道资源 - 但是如果你将记录集设置为NOTHING为

很快就完成它应该可以释放这些资源 - 但

秒方法会明显加快。


- WmArrays让我成为一个更好的人 Morris

-

William Morris

产品开发,Seritas LLC

" Rabbit63" <胡****** @ hotmail.com>在消息中写道

news:e3 ************** @ tk2msftngp13.phx.gbl ...
I don''t know about resources - though if you set the recordset to NOTHING as
soon as you''re done with it that should free those resources up - but the
second method will be noticeably faster.

- Wm "Arrays made me a better person" Morris
--
William Morris
Product Development, Seritas LLC
"Rabbit63" <hu******@hotmail.com> wrote in message
news:e3**************@tk2msftngp13.phx.gbl...
嗨:

我想在clicnt
浏览器的数据库表中显示一组记录。我有两种方法可以做到这一点(用JScript编写):

1.第一种方式是:

<%
var sql =" select firstname from table1" ;;
var obj = new ActiveXObject(" ADODB.Recordset");
obj.open(sql,conn);
while(!obj.EOF)
{
Response.write(obj(" firstname")+"< br>");
obj.movenext();
}
obj.close( );
%>

2.第二种方式是:
<%
var arr = new Array();
var sql = 从table1中选择firstname;
var obj = new ActiveXObject(" ADODB.Recordset");
obj.open(sql,conn);
while(!obj.EOF)
{arr [arr.length] = new String(obj(" firstname"));
obj.movenext();
}
obj.close ();

......

for(i = 0; i< arr.length; i ++)
{
文件。写(arr [i] +"< br>");
}
%>

我认为第二种方式更灵活但它会比第一种方式更多的记忆,因为数组arr会留下更多的记忆。我/我是否正确?您认为第二种方式需要更多服务器资源吗?
你有更好的想法改进第二种方式吗?

我尝试第二种方式的原因是我想制作我的服务器端程序(大多数是用JScript编写的) )是基于对象的(不是OOP)
编程风格。但我怀疑基于对象的程序会占用更多的内存或服务器资源。

非常感谢你!



Hi:

I want to show a set of records in the database table on the clicnt browser. I have two ways to do this (writen in JScript):

1.The first way is:

<%
var sql = "select firstname from table1";
var obj=new ActiveXObject("ADODB.Recordset");
obj.open(sql, conn);
while(!obj.EOF)
{
Response.write(obj("firstname") + "<br>");
obj.movenext();
}
obj.close();
%>
2. The second way is:
<%
var arr=new Array();
var sql = "select firstname from table1";
var obj=new ActiveXObject("ADODB.Recordset");
obj.open(sql, conn);
while(!obj.EOF)
{
arr[arr.length] = new String(obj("firstname"));
obj.movenext();
}
obj.close();

......
for(i=0;i<arr.length;i++)
{
document.write(arr[i] + "<br>");
}
%>
I think the second way is more flexible but it will take nuch more memory
than the first way, because the array "arr" will take more memory. Am I
correct? Do you think the second way will need more server resources? Do you have better idea to improve the second way?

The reason that I tried the second way is that I wanted to make my server
side programs (most writen in JScript) be object-based (not OOP) programming style. But I am doubt that the object-based programs will take much more
memory or server resources.

Thank you very much!

Qing



这将执行两种方法。


var sql =" select table1 from first1" ;;

var obj = new ActiveXObject(" ADODB.Recordset");

obj.open(sql,conn,adOpenForwardOnly,adLockReadOnly);

var arr = obj.GetRows;

obj.close();


-dlbjr


明确的施舍决议
This will out perform both methods.

var sql = "select firstname from table1";
var obj = new ActiveXObject("ADODB.Recordset");
obj.open(sql,conn,adOpenForwardOnly,adLockReadOnly );
var arr = obj.GetRows;
obj.close();

-dlbjr

Discerning resolutions for the alms


" WIlliam Morris"写道:
"WIlliam Morris" wrote:

我不知道资源 - 尽管如果你把记录集设置为NOTHING,一旦你完成它就应该免费
那些资源 - 但第二种方法会明显更快。

I don''t know about resources - though if you set the recordset
to NOTHING as soon as you''re done with it that should free
those resources up - but the second method will be noticeably
faster.




重新阅读他的帖子。他在服务器上使用JScript,所以没有必要将记录集设置为NOTHING(也不是这样做的)。


而且我不相信第二个会更快。

VBScript / IIS4可能是这样,但这是完全不同的情况。正如其他线程中提到的那样,VBScript和JScript具有不同的优势和
弱点,每个任务都比其他任务更快。

-

戴夫安德森


未经请求的商业电子邮件将以



Re-read his post. He''s using JScript on the server, so there is no need to
set the recordset to NOTHING (nor a means to do so).

And I''m unconvinced the second will be faster. That may have been true with
VBScript/IIS4, but this is a completely different situation. As has been
noted in other threads, VBScript and JScript have different strengths and
weaknesses, and each does some tasks faster than the other.
--
Dave Anderson

Unsolicited commercial email will be read at a cost of

这篇关于哪种方式会占用更多内存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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