[XForms] Re: Xforms : popup menus

laurent FOURNIER laurent.fournier at lapp.in2p3.fr
Thu Apr 1 02:44:03 EST 2004


Jean-Marc Lasgouttes wrote:

>Sure. I memory very tight in your setting?
>
Yes, a process cannot get more than 16Mb (but this can be tuned). The 
total memory is usually 32Mb (some CPUs have up to 96Mb), no hard drive

>There is not real pointer to menu items, since item is an array. All
>the code that I have seen sets the first entry (item[0]) to 0 when
>needed, so there should not be any problem [actually, I know there is
>a problem, since you experienced it. But I fail to see it]
>
>fl_setpup_maxpup does reset title and item[0] for each new popup. It
>seems however that it fails to reset parent, and this may cause
>problems with the following test in find_index:
>	if (!p->title && !p->item[0] && !p->parent)
>  
>
I did not experience problems with this data... but it was perhaps set 
to values which do not put the system in trouble. The forms are always 
created "on the fly" as the user needs them. The only form that is 
created at startup is the main one since there can be a really huge 
number of forms.

>Then fl_setpup_maxpup would read:
>
>int
>fl_setpup_maxpup(int n)
>{
>    int i;
>
>    if (n < FL_MAXPUP)
>	return FL_MAXPUP;
>
>    fl_init_pup();
>
>    menu_rec = fl_realloc(menu_rec, n * sizeof(*menu_rec));
>    for (i = fl_maxpup; i < n; i++)
>    {
>	menu_rec[i].title = 0;
>	menu_rec[i].item[0] = 0;
>	menu_rec[i].parent = 0; /* <================== */
>    }
>
>    return fl_maxpup = n;
>}
>  
>
I had a look on the code, I think this initialization is quite full of 
sense ! :-)

>But menu_rec->item is not really a pointer, is it?
>
Not exactly, you are right.

>I doubt that this difference in space will be important enough. I
>guess there many other sources of bloat in xforms :)
>
Of course. I like things that are compact, but this is purely personal.

>What we do in LyX is that we maintain our own maxpup variable that
>starts at 32 and we call fl_setpup_maxpup as needed. The (C++) code
>looks like
>
>int get_new_submenu(vector<int> & smn, Window win)
>{
>	static size_type max_number_of_menus = 32;
>	if (smn.size() >= max_number_of_menus)
>		max_number_of_menus =
>		    fl_setpup_maxpup(static_cast<int>(2*smn.size()));
>[...]
>
>Here, smn holds the list of menus that have been allocated. This is
>used to deallocate them when they ar enot needed any more (menus are
>generated just before displaying them in LyX).
>  
>
I tried a code which is strongly inspired from yours for menu creation 
(to get the real number of available popups : just call 
fl_setpup_maxpup(0) ! this returns the number of avalable popups :-) ). 
Thanks to a preemptive handler on FL_FREEMEM events(for down counting), 
my application now allocates just enough space. Thank you for the advice !

>I'll try to come up with a patch against xforms 1.0.90. I'd be
>interested to see whether it fixes your problems.
>
>JMarc
>  
>
I let you know as soon as possible, I thank you once again for your work.

Laurent.



More information about the Xforms mailing list