DeadHead@cup.portal.com (Bruce M Ong) (09/29/90)
hi world - I seem to have run into a show stopper for a MOTIF project I am working on... here is the deal: The motif dialog widget - the selection box dialog - does not seem to clean up its internal data when a new XtSetArg() is called with a different item count and a different item list than the previous call. The following is a short program that produces this problem: ------------------------- #include <stdio.h> #include <X11/Intrinsic.h> #include <X11/StringDefs.h> #include <X11/Xutil.h> #include <Xm/Xm.h> #include <Xm/SelectioB.h> #include <Xm/BulletinB.h> Widget s; void cb(w,id) /* cyclic timeout call back */ Widget w; XtIntervalId id; { XmString item; int n; Arg wargs[3]; item= XmStringCreateLtoR("item1",XmSTRING_DEFAULT_CHARSET); n = 0; XtSetArg(wargs[n],XmNlistItems,&item);n++; XtSetArg(wargs[n],XmNlistItemCount,1);n++; XtSetValues(s,wargs,n); XmStringFree(item); XtManageChild(s); XtAddTimeOut(1000,cb,NULL); } main(argc, argv) int argc; char *argv[]; { Widget parent; Widget bb; parent = XtInitialize(argv[0],"test",NULL,0,&argc, argv); bb = XtCreateManagedWidget("bb",xmBulletinBoardWidgetClass, parent,NULL,0); s = XmCreateSelectionDialog(parent,"sbox",NULL,0); /* * add a cyclic timeout */ cb(s,NULL); XtRealizeWidget(parent); XtMainLoop(); } /* the cyclic timeout is something that i *have* to use in my real program - which basically wakes up every n seconds and checks to see if a disk directory contains any files. If the directory does contain files, it displays the directory file names in the selection box */ -------------------------------- And here is my ps -el output on systemV (interactive unix 2.0.2) for this program ("test") - the script I used to produce this data is #!/bin/csh while (1) ps -el | grep test >> /tmp/data sleep 30 end ----------------- Memory Usage | 10 S 212 1692 423 19 26 24 40256c 302 d00b9c08 ttyp2 1:03 test 10 S 212 1692 423 17 26 24 40256c 308 d00b9c08 ttyp2 1:08 test 10 S 212 1692 423 18 26 24 40256c 314 d00b9c08 ttyp2 1:13 test 10 R 212 1692 423 11 69 24 40256c 320 ttyp2 1:18 test 10 R 212 1692 423 24 76 24 40256c 326 ttyp2 1:23 test 10 R 212 1692 423 15 71 24 40256c 332 ttyp2 1:27 test 10 R 212 1692 423 18 72 24 40256c 338 ttyp2 1:32 test 10 R 212 1692 423 25 76 24 40256c 344 ttyp2 1:37 test 10 S 212 1692 423 18 26 24 40256c 350 d00b9c08 ttyp2 1:42 test 10 S 212 1692 423 20 26 24 40256c 355 d00b9c08 ttyp2 1:47 test 10 R 212 1692 423 17 72 24 40256c 361 ttyp2 1:52 test 10 S 212 1692 423 20 26 24 40256c 367 d00b9c08 ttyp2 1:57 test 10 R 212 1692 423 18 73 24 40256c 373 ttyp2 2:02 test 10 R 212 1692 423 23 75 24 40256c 379 ttyp2 2:07 test 10 R 212 1692 423 20 74 24 40256c 385 ttyp2 2:12 test as we can see, there does seem to be a memory leak. But what I am not sure is if there is something that I am doing wrong, or if it is a MOTIF problem. I have not checked the behavior of the widgets not managed under a dialog shell and see if changing their item list (i.e. for file selection box widget, list widget, selection box widget, etc.) will cause the same problem. If there is a memory leak there, then that means if you leave your program running long enough, it will run out of memory... any hints and ideas would be much appreciated. Thanks! (please email) ------- bruce deadhead@cup.portal.com
tjhorton@ai.toronto.edu ("Timothy J. Horton") (09/29/90)
DeadHead@cup.portal.com (Bruce M Ong) writes: > The motif dialog widget - the selection box dialog - does >not seem to clean up its internal data when a new XtSetArg() is called >with a different item count and a different item list than the previous call. (Keep in mind that even if the widget cleans up, memory fragmentation will eventually cause your process to perpetually grow, however slowly.) I was worried enough about this problem that I wrote my own selection code -- using a draw window and a text widget -- because I use swap in *particularly* long lists -- 2000 at a time -- quite often. I can simply reset the item list pointer (to an existing array of string pointers) and the item count, and clear the window. It saves both in terms of memory utilization and processing. The code is maybe 300 lines, and carefully debugged, but it's not "widgetized" -- packaged up as a new widget. That would have been far too much work, to create such a specialized wheel, because I haven't written full-fledged widgets before. If anybody is experienced at writing widgets and would be willing to contribute this to the world, I'd contribute what I could. tjhorton@ai.toronto.edu uunet!jtsv16!geac!tse!cont1
DeadHead@cup.portal.com (Bruce M Ong) (10/02/90)
Few days ago I reported: > > I seem to have run into a show stopper for a MOTIF project I am >working on... here is the deal: > > The motif dialog widget - the selection box dialog - does >not seem to clean up its internal data when a new XtSetArg() is called >with a different item count and a different item list than the previous call. > apparently, from various replies on the net, this is a known problem in MOTIF 1.0 XmString.c module - apparently it has quite few memory leaks. One reply suggested that I stay away from MOTIF til v1.1. Now, my question is - 1.1 is available from OSF but not from ISC. Can I buy the source (after this fiasco - trying to explain to my mgr that we'd have to delay product introduction for 1-2 weeks because it would not look very professional for our product to crash X completely with "XtMalloc() - not enough memory" - I'd like to get the source and forget about ISC's port) and directly compile it with the ISC's Xlib without too much hassel? Has anybody successfully done this? What's OSF's fee on the source and what kind of licensing agreement is there for distribution of binary programs? muchas glacias - bruce deadhead@cup.portal.com
cpcahil@virtech.uucp (Conor P. Cahill) (10/02/90)
In article <34433@cup.portal.com> DeadHead@cup.portal.com (Bruce M Ong) writes: >What's OSF's fee on >the source and what kind of licensing agreement is there for distribution >of binary programs? The source fee is $1,000. There is no fee for distributing programs that have been linked with the motif libraries. There is only a binary re-distribution fee if you are going to sell copies of the libraries and/or programs (like the motif window manager). -- Conor P. Cahill (703)430-9247 Virtual Technologies, Inc., uunet!virtech!cpcahil 46030 Manekin Plaza, Suite 160 Sterling, VA 22170
DeadHead@cup.portal.com (Bruce M Ong) (10/03/90)
I remember somebody once emailed me that there are at least two motif toolkit vendors for ISC2.02 - ISC, and somebody else. Who is the other guy? Any reviews as to the quality of the other guy's toolkit? (please email) thanks - bruce deadhead@cup.portal.com