Please think a website which has min. 30.000 site visitors daily.
The website was coded with asp using sql 2008

You will find a lot of lines and thus many database connections

I personally use recordset like following

set rs=server.createobject.......
set rs2=server.createobject.......
set rs3=server.createobject.......

I put these line towards the top of the page. i quickly rely on them after i need like

rs.open "select........."
rs.close

I personally use them maybe 3 time for every page.

and, at the end from the page I write

set rs=nothing
set rs2=nothing
set rs3=nothing

Now my real question is that: will it cause memory leak or other problem?

or must i use like

set rs=server.createobject
rs.open
rs.close
set rs=nothing

I am talking about must i create object whenever i want and kill it after i finish by using it each time

It's better should you produce the recordsets as disconnected in the DB (clearing the bond)

Dim rs, cmd
Set rs = server.createobject("ADODB.Recordset")
Set cmd = server.createobject("ADODB.Command")

' Init the ADO objects  & the stored proc parameters
cmd.ActiveConnection = GetConnectionString()
cmd.CommandText = sqlstmt
cmd.CommandType = adCmdText

' Execute the query for readonly
rs.CursorLocation = adUseClient
rs.Open cmd, , adOpenForwardOnly, adLockReadOnly


' Disconnect the recordset
Set cmd.ActiveConnection = Nothing
Set cmd = Nothing
Set rs.ActiveConnection = Nothing

In most cases, by hand eliminating recordsets along with other objects is excessively careful, especially in the finish of the page.

VBScript has generated-in garbage collection and finalizers. The moment an item is no more recommended*, it will likely be GC'd and it is class_terminate method known as. Thus, should you produce a recordset in the function and don't pass the reference outdoors the function, then it will likely be collected and it is assets freed in the finish from the function when it's no more recommended. Should you place an item inside a global variable, it it's still collected once the script has finished running. You can't result in a memory leak in this way. Because of this, unsetting objects in the finish from the script is useless, because they wouldn't survive the finish from the script anyway unless of course you deliberately insert them in an extended-resided collection for example Session or Application.

*VBScript's garbage collection guarantees prompt collection, consider it only counts references, it may be misled by circular references. Take this into account also it should not result in any problem.

Generally, if there's an item that you'll require for a short while, referencing it inside a function local variable or as the topic of a with block is the greatest solution. The only real reason to by hand unset an item is that if a) you've got a real, shown have to release assets and only b2) the item under consideration is recommended in global scope lengthy after it's needed or b2) the item is a component of the circular reference.

Now, inside your particular situation, it appears such as the only resource worth worrying about whatsoever may be the database connection. In case your database is getting trouble maintaining using the load, then terminating connections quickly might help. You will find two ways to get this done. First, by hand unset each recordset whenever you no more require it, or by hand unset each recordset's connection. Second, make use of the recordsets or connections inside a more compact scope to ensure that they'll be taken proper care of instantly. If you just need the information, for instance, you'll be able to make use of the GetRows technique to get the information with no overhead of keeping round the recordset. During my code, I never use recordsets, instructions, or connections directly, but instead use assistant functions that take proper care of the gory ADO particulars and return the particular data I needed.

Technically you need to destroy objects as quickly as possible.

That being stated, I actually do the majority of my pages while you do and have not had any problems