Hello all, my first post here and I hope that someone can help me.
In one of my Excel applications (well it may as well be Word, Access as it's mostly pure VBA but I am using Excel as I can give away the tool for others to use) I do a lot of number crunching.
And because of the amount of data and the fact that it won't fit into into a pre-2007 Excel spreadsheet (and this would be too slow anyway) I am doing the number crunching in VBA.
Now I am doing this by holding all the data in a linked list. The linked list can be rather large with each element in the list (a Class) containing about 120 variables or so and a pointer to the next list element.
Now, there is no doubt that the list works. I can create items at the end of the list and run up and down the thing as fast as I like.
I decided to use my own linked list rather than a Collection class (which is effectively the same thing but using a class which Microsoft has rolled rather than my own). The one drawback with a Collection is that it's too slow. With my linked list data structure I can do my analysis in ten minutes. On the same machine, with the same data it takes about twelve hours with the Collection. I have even put the data into an array in memory and that's also too slow.
So, what's then the problem? Well, the issue with VB/VBA is that there is no real mechanism for the programmer to force a dispose of an element. Instead we have to rely on Excel or the operating system to clear up after ourselves.
Now if the linked list were small this isn't an issue but this particular list that I have makes Excel crash when it tries to do its own data cleaning. The list works fine; the data is good and the analysis is good but I don't want Excel to crash each time I do a run. In this case there could be up to about 300,000 elements in the list.
Now, if I use a Collection or an array then I don't have this problem but Excel has a problem with its own garbage collection when I am trying to dispose of something this large.
So, any ideas? Is there any way that I can force Excel to actually dispose of an instanced object properly without it going Phut! on me?
Sorry for the long winded message but this is driving me nuts and I wondered if someone can spot The Really Obvious answer (othe than using C or C++).
Cheers
Malc
In one of my Excel applications (well it may as well be Word, Access as it's mostly pure VBA but I am using Excel as I can give away the tool for others to use) I do a lot of number crunching.
And because of the amount of data and the fact that it won't fit into into a pre-2007 Excel spreadsheet (and this would be too slow anyway) I am doing the number crunching in VBA.
Now I am doing this by holding all the data in a linked list. The linked list can be rather large with each element in the list (a Class) containing about 120 variables or so and a pointer to the next list element.
Now, there is no doubt that the list works. I can create items at the end of the list and run up and down the thing as fast as I like.
I decided to use my own linked list rather than a Collection class (which is effectively the same thing but using a class which Microsoft has rolled rather than my own). The one drawback with a Collection is that it's too slow. With my linked list data structure I can do my analysis in ten minutes. On the same machine, with the same data it takes about twelve hours with the Collection. I have even put the data into an array in memory and that's also too slow.
So, what's then the problem? Well, the issue with VB/VBA is that there is no real mechanism for the programmer to force a dispose of an element. Instead we have to rely on Excel or the operating system to clear up after ourselves.
Now if the linked list were small this isn't an issue but this particular list that I have makes Excel crash when it tries to do its own data cleaning. The list works fine; the data is good and the analysis is good but I don't want Excel to crash each time I do a run. In this case there could be up to about 300,000 elements in the list.
Now, if I use a Collection or an array then I don't have this problem but Excel has a problem with its own garbage collection when I am trying to dispose of something this large.
So, any ideas? Is there any way that I can force Excel to actually dispose of an instanced object properly without it going Phut! on me?
Sorry for the long winded message but this is driving me nuts and I wondered if someone can spot The Really Obvious answer (othe than using C or C++).
Cheers
Malc