|
-
April 20th, 1999, 01:56 PM
#1
allocating memory
If I do a CListCtrl m_wndList[20]; would this allocate alot of memory if the user only "makes" the program use the first two.. for example
(it sure is ugly to do like this!)
The thing is i dont know from the start how many ctabctrl's the user needs,, its up to him...
-- Henrik
-
April 20th, 1999, 05:21 PM
#2
Re: allocating memory
I'm not sure how much memory or time it would take to allocate 20 CListCtrls on the stack but I doubt it's much. Try it and see.
If you really want to play it conservatively, use an array of pointers (CListCtrl* m_pWndList[20]) and allocate each control as needed (and only once). So you'll just need to remember to first initialize the array in your constructor (memset(m_pWndList, 0, sizeof(m_pWndList) and then clean it in your destructor:
for (int i = 0; i < sizeof(m_pWndList) / sizeof(*m_pWndList); i++)
{
if (m_pWndList[ i ])
delete m_pWndList[ i ];
}
That's the price for conservatism... but it may be worth it.
Alvaro
-
April 20th, 1999, 06:42 PM
#3
Re: allocating memory
Alvaro's method is good, or craete tham as you need them and put them into a CObList
Sally
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|