Re: ClistCtrl memory problems

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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.
****

thx for all replys
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.



Relevant Pages

  • Re: grow list by tail, pointer example recipe -- please comment
    ... manufacturing a pointer with that address. ... the next cons cell. ... believe these lists are in consecutive memory locations. ...
    (comp.lang.lisp)
  • Re: Fast linked list
    ... > amounts of memory rather than huge chunks of it. ... random insertions into a vector/dynamic array are not as slow ... to cause a cache miss. ... some hard numbers on speed differences between lists and arrays. ...
    (microsoft.public.vc.mfc)
  • Re: Fast linked list
    ... > amounts of memory rather than huge chunks of it. ... random insertions into a vector/dynamic array are not as slow ... to cause a cache miss. ... some hard numbers on speed differences between lists and arrays. ...
    (microsoft.public.vc.language)
  • Re: Pointer To A Vector Elements While Still Adding
    ... As I understand it, when you add an element to the end of a list, memory is ... there is sufficient capacity. ... elements to 10,000 lists. ... better to allocate them statically). ...
    (comp.lang.cpp)
  • Re: teaching a child - console or GUI
    ... >> Are these objects very complex, or are they really a bunch of pointers ... >> One can hold a lot of those on disk ... ... Sure they do - however since memory is finite ... lists of pointers on disk, extract files of frequent search fields in ...
    (comp.lang.pascal.delphi.misc)