Re: ClistCtrl memory problems
- From: Joseph M. Newcomer <newcomer@xxxxxxxxxxxx>
- Date: Sun, 26 Nov 2006 22:51:25 -0500
Because, perhaps, you are using 20-24K additional memory?
It is also a good idea to rename those controls from the relatively useless names like
IDC_LIST1 to something that makes sense, such as IDC_MAIN_LIST. Otherwise, you end up
with a bunch of meaningless names in your code.
joe
On 26 Nov 2006 15:13:22 -0800, wojjed@xxxxxxxxx wrote:
hi.*****
In my project i got 6 lists, where one of them is main list. When im
clicking on item in main list, the rest of lists should be filled.
Everything works fine, but each fill increases memory by 20-24 kB
(checked in task manager). Why ?
the filling of one list looks like that :
event: OnNMClickList1(NMHDR *pNMHDR, LRESULT *pResult) on main list
{......
mListSpecialConditions.DeleteAllItems();
char * warunki;
It would be a really, really good idea to eliminate from your program every possible
instance of char *. LPTSTR would be good. 'char' is inviting disaster because it won't
work if you have to convert to Unicode. For that matter, why char * instead of CString?
****
warunki =****
zapis_dzienny.obrob_zapis_warunkow(tablica_ws,licznik_warunkow);
for ( iq = 0; iq < licznik_warunkow; iq++ )
{
_itoa_s( (iq+1), _buf, 30, 10);
lp = _buf;
I don't suppose the concept of CString::Format has crossed;your mind? Programming like
you are on a PDP-11 in 1975 is a bit quaint. Why the redundant assignment to lp? Why not
use _buf as the parameter to InsertItem? I presume _buf is a local variable, but when you
show code, it is essential to show the declarations of all the variables, so that
apparently nonsensical assignments like the one above can be understood.
****
Index_warunkow = mListSpecialConditions.InsertItem( iq, lp);****
mListSpecialConditions.SetItemText( Index_warunkow, 1,
(CString)&warunki[(0+iq*2)*60] );
mListSpecialConditions.SetItemText( Index_warunkow, 2,
(CString)&warunki[(1+iq*2)*60] );
}
}
.....}
any sugesstions ?
GIven that nothing ;you have shown here is relevant to the problem you described, it is
impossible to actually suggest any alternative. It would be useful to know, for example,
if this memory increase is constant over hundreds of assignments or you've measured just
two or three assignments. Are there any allocations going on in any of the areas you have
not shown? The code is far too sketchy to make any recommendations.
****
Joseph M. Newcomer [MVP]
thx for all replys
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.
- References:
- ClistCtrl memory problems
- From: wojjed
- ClistCtrl memory problems
- Prev by Date: Re: Popup menu positioning
- Next by Date: Re: MFC Strings English -> German ?
- Previous by thread: ClistCtrl memory problems
- Next by thread: Re: Refreshing a window (simulating F5)
- Index(es):
Relevant Pages
|