Click to See Complete Forum and Search --> : ending program takes 5 minutes


koloite
May 4th, 2001, 05:04 AM
I have made an application in VB that reads about 30000 records from several databases. These records are stored as objects in VB. The problem is that when I try to end the program, this takes several minutes. During this shutdown my harddrive is constantly being accessed. All references to objects are allways set to Nothing, and I have also tried to abruptly end the program using the End statement, but this only makes it worse.

If I kill the program in the Process viewer util the program stops immedately, also if the program is allready in the shutdown process.
If I try to end the program using the Windows task manager, the program first tries to shutdown nicely, then the task manager starts complaining that the program is not responding. I can then stop the program by clicking End task without waiting for the program to respond.

Is there any way to abruptly stop a program in VB? I then first close all database connections etc. and then want to kill the process as this is basically what I do using the process viewer.

Cimperiali
May 4th, 2001, 05:10 AM
"about 30000 records from several databases"
Now, it may be time to shut down is related to time to close all those databases
to test this, once you're sure you have closed all them from vb, wait for 5 minutes, then close your program again. Any difference?
If so, it will not help you to kill vb program. You should be look for a different way to open/read from those several databases (I imagine at least one of those readings retrieve more records than you suspect...)

Special thanks to Lothar "the Great" Haensler, Tom Archer, Bruno Paris and all the other wonderful people who made and make Codeguru a great place. Come back soon, you Gurus.

koloite
May 4th, 2001, 05:28 AM
Thanks for the suggestion!

I have tried to close the databases and then waiting before proceeding with the shutdown process, but it did not help. And all the records being read are really needed for the program...

The problem is most probably related to the amount of objects loaded, because I also have some smaller test databases with in total about 8000 records, and this works fine...

Cimperiali
May 4th, 2001, 05:36 AM
...as objects? Are you dinamically loading 30.000 objects? Can't you use array of objects of same type?


Special thanks to Lothar "the Great" Haensler, Tom Archer, Bruno Paris and all the other wonderful people who made and make Codeguru a great place. Come back soon, you Gurus.

Cakkie
May 4th, 2001, 05:57 AM
Why not use the recordset and load the data in an object if needed?

Tom Cannaerts
slisse@planetinternet.be

Programming today is a race between software engineers striving to build bigger and better idot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook

koloite
May 4th, 2001, 06:01 AM
The recordsets contain quite a lot of grouping data meaning that using the recordsets directly without translating them into objects would be:
1: Quite difficult to reorganize the data (sometimes needed)
2: Extremely slow compared to the current solution using direct references to the objects (user clicks a record, and a reference to the object is immedately known. Using the recordsets would need quite a lot of search work)

What I really need is some way of efficently cleaning up the objects...

koloite
May 4th, 2001, 06:12 AM
The objects are referenced through several variables in the program. Using arrays these references could be replaced by indices in the arrays, but I would then get problems when deleting records from the arrays. Either I would have to make some kind of special value indicating the element has been deleted or I would have to move the rest of the elements of the array, redim the array and update all the indices.
Because the user can add, modify and delete records with the program the storage must be dynamical.

I also just made a small test program containing one array of some simple class. Filling this array with 30000 instances worked fine, 50000 worked ok, 70000 started to show problems and 100000 almost crashed my computer...

Cimperiali
May 7th, 2001, 02:29 AM
As I am not used to this - but it seems interesting - may you provide a small example?
Thanks.

Special thanks to Lothar "the Great" Haensler, Tom Archer, Bruno Paris and all the other wonderful people who made and make Codeguru a great place. Come back soon, you Gurus.

sfieldho
May 7th, 2001, 01:01 PM
Why are you creating objects for every record in the recordset - in an array or otherwise? Surely, the user will only be processing (insert/amend/delete) one record at a time. Why not create the application specific objects only for the record being processed and let the recordset object itself act as the container for the bulk of the data?