Hello, I'd like some advice please.
I have a list view control, and a custom control which displays the same data but differently. The data in the custom control is kept in a linked list, and I wouldn't expect there to be much more than 1000 items in the list. The user can change the view between the listview, or the custom control. When this happens is it better to destroy the list and create the custom control - add all the data to the control and then show it, upon changing the view again destroy the custom control and add all the data to the listview then show it. Or, show I have both control created at all times and just use show/hide the relevant window?

I assume the second is faster, but uses more memory slightly more memory. I understand that 1000 items isn't that many (8dwords per struct -> approx 32K of memory), but just wondering if the second is definately the best?
Thanks :stupid:
Posted on 2004-07-10 08:12:49 by adamjjackson
The first way is better.
Now,you have about 1000 items but later you maybe have more.

Posted on 2004-07-12 15:48:06 by Anonymous
That's the way I'm doing it but I am surprised...
Posted on 2004-07-13 04:21:13 by adamjjackson
Classic 'On Demand' vs 'Frequently Accessed' arguement.

If the data is constantly accessed, Hide & Show, but your keeping memory tied up doing it. For quick access.

If the data is on demand access, then Create & Destroy, keeping memory cleaned up for other needs. For as loading data wait required.

Then it gets back to you the programmer, method is dictated by usage. So what's the usage and you can figure out the method.

Regards, P1 :cool:
Posted on 2004-07-13 10:07:45 by Pone
Thanks, I had kinda got that far already, just wondered if it would be weighted more heavily in one direction. For example most modern computers have a large amount of memory (do they not?!), so having the two controls loaded up might not have been a bad idea if memory usage isn't that big a deal...

Now you have pointed out that it is purely dictated by usage I have the method figured out :alright:
Posted on 2004-07-13 11:45:09 by adamjjackson
Just a thought. Check for free memory, then determine dynamically the method, if it's worth the extra coding.

Regards, P1 :cool:
Posted on 2004-07-13 13:51:50 by Pone
Sorry to chime in so late on this.

Anyway, if you have your data already in a linked list, you can have the listview be a "virtual listview" so when it is ready to draw the items in view the listview will call some callback handlers to allow you to format your data for the view.

You can modify your custom control to be an approach like a virtual list view where it will only draw items which are in view.

It is a lot of work to set things up like this but once you have it, memory is kept to a minimum while performance is actually improved (because you are only drawing what can be seen and no set up time to populate the controls with data).

Posted on 2004-11-04 22:41:04 by Relvinian