Set db = Nothing. Is it necessary? 
Author Message
 Set db = Nothing. Is it necessary?

I've heard a couple of times in this newsgroup about setting an object
as database or dynaset to Nothing after closing.
Is it really necessary? If yes why? The manuals suggest only
closing so what will happen to applications that don't do that?
Cezar


Thu, 25 Dec 1997 03:00:00 GMT  
 Set db = Nothing. Is it necessary?

Quote:

>I've heard a couple of times in this newsgroup about setting an object
>as database or dynaset to Nothing after closing.

When you create a db or dynaset for a DAO in VB, windows will allocate some of its
resources to the db objects.  If you do not clear them explicitly, you will not get
them back.  This is true of any declared object type (OLE, Database, FORM,
CONTROL).  When you create it in code, you are responsible for the cleanup.)

I created an app using ODBC.  All database interaction was handled in code rather
than bound countrols.  After opening and closing numerous snapshots and dynasets I
began getting Out of Memory Errors.  The error was not telling me I was running out
of Ram, but that I was runnning out of resources (the 64k allocated to Windows for
the GDI, USER, and KERNEL)  As soon as I used the SET....NOTHING the problem when
away.  However, if I repeated the same thing under NT I never got the error...  No
resource limit under NT....

To answer your question, no you dont have to, but if you are using many different
snapshots or dynasets, you might want to consider it.



Thu, 25 Dec 1997 03:00:00 GMT  
 Set db = Nothing. Is it necessary?

Subject: Re: Set db = Nothing. Is it necessary?

Quote:
>I've heard a couple of times in this newsgroup about setting an object
>as database or dynaset to Nothing after closing.
>Is it really necessary? If yes why? The manuals suggest only
>closing so what will happen to applications that don't do that?

     Setting it to nothing frees the memory.  Close does not.

_
"640K ought to be enough for anybody." (Bill Gates, 1981)
QWicKeSST - The ultimate database QWK reader, and NO limits. #BLYGJOMK
Special Compile: 1.008A (Alpha)

'[1;35;40m-=> Delphi Internet Jet SST v3.013A (Alpha) - (C) PBE



Sat, 27 Dec 1997 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. When is Set myVar = Nothing Necessary?

2. Is it necessary to set resultsets to nothing?

3. db.close or set db = nothing or togheter

4. To set = nothing or not to set = nothing...

5. Set db=nothing?

6. necessary to close db connections?

7. Detecting if DB is set before set to nothing?

8. setting permissions to Unsured db from secured DB

9. db, ws= nothing / rst.close

10. Can set a ref to 1 open db but not another open db - error 3045

11. help: DB app does nothing

12. help: DB app does nothing

 

 
Powered by phpBB® Forum Software