[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference bulova::decw_jan-89_to_nov-90

Title:DECWINDOWS 26-JAN-89 to 29-NOV-90
Notice:See 1639.0 for VMS V5.3 kit; 2043.0 for 5.4 IFT kit
Moderator:STAR::VATNE
Created:Mon Oct 30 1989
Last Modified:Mon Dec 31 1990
Last Successful Update:Fri Jun 06 1997
Number of topics:3726
Total number of notes:19516

1449.0. "XCopyArea gobbles memory?" by SKYLRK::LOSCHEN () Fri Sep 15 1989 14:56

I am working with a customer who needs to create a "falling raster"
display.  The idea is to continuously update a screen with data from a
satellite.  The screen should appear to be random blobs, that move from 
top to bottom in real time.  The goal is to shift the whole display down by 
1 pixel each "sweep" (much like an oscilloscope), once per second.  The code 
I have included below does something very similar, but instead of the random 
bits, it continuously does an XCopyArea of 2 1020x1 pixmaps - one white and 
one black.

The problem I encounter, is after a short while, the CPU that is running
the client, begins to page/swap like crazy.  On a DS3100 with 16Mb and 65Mb of
swap, the program dies because of insufficient swap after ~450 reps. The 
problem is always on the client end regardless of where the server is located.  (I have not tried ru
	 
Finally the questions!!  Why does XCopyArea allocate memory every
time it is called?  Is this a feature, bug, or way of life?  Any way
around it?

If XCopyArea has to work that way, is there a better way of solving this
problem?  I have experimented with images, but there seems to be a fair
amount of overhead, getting an image to the screen.  I also had a problem
getting an image to appear on a color display - probably my fault.

Any help, suggestions, comments, tips, or pointers, would be most
appreciated.

Thanks
Brent Loschen

+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+

#include <stdio.h>
#include <X11/DwtAppl.h>       /* DECwindows Toolkit */

/*
#include "im3.bitmap"
#include "im4.bitmap"
*/

#define im3_width 1024
#define im3_height 1
static char im3_bits[] = {
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};

#define im4_width 1024
#define im4_height 1
static char im4_bits[] = {
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

main(argc,argv)
int argc;
char *argv[];
{
    Widget toplevel, main, dbox, widg, button;
    int i,j,k;
    Pixmap pix3,pix4;
    Display *dpy;
    Window win;
    Arg al[2];
    unsigned long fg,bg;
    int scr,depth;
    GC gc;
    XGCValues xgcv;
    

    toplevel = XtInitialize("image","test",NULL,0,&argc,argv);
    main = DwtMainWindow(toplevel,"",0,0,1020,860);
    XtManageChild(main);
    dbox = DwtDialogBox(main,"",0,0,0,DwtLatin1String("x"),DwtWorkarea,0,0);
    XtManageChild(dbox);
    XtRealizeWidget(toplevel);
    widg = DwtWindow(dbox,"",0,0,1020,860,NULL);
    XtManageChild(widg);

    dpy = XtDisplay(widg);
    win = XtWindow(widg);
    scr = DefaultScreen(dpy);
    fg=BlackPixel(dpy,scr);
    bg=WhitePixel(dpy,scr);
    depth=DisplayPlanes(dpy,scr);
    pix3=XCreatePixmapFromBitmapData(dpy,win,im3_bits,1020,1,fg,bg,depth);
    pix4=XCreatePixmapFromBitmapData(dpy,win,im4_bits,1020,1,fg,bg,depth);
    XtSetArg(al[0],DwtNbackground,&xgcv.background);
    XtSetArg(al[1],DwtNforeground,&xgcv.foreground);
    XtGetValues(widg,al,2);
    gc = XtGetGC(widg,GCForeground|GCBackground,&xgcv);
    for(i=0;i<500;i++){
    	for(j=0;j<860;j++){     /* In here is where the pixmap would get loaded 
				   with the new raster info */
	    for(k=0;k<i;k++){	/* This loop would go away */
    	    	XCopyArea(dpy,pix3,win,gc,0,0,1020,1,0,j);
	    	j++;
	    }
    	    XCopyArea(dpy,pix4,win,gc,0,0,1020,1,0,j);/*this too,would go away*/
        }
    }
}

T.RTitleUserPersonal
Name
DateLines
1449.1AITG::DERAMODaniel V. {AITG,ZFC}:: D&#039;EramoFri Sep 15 1989 20:446
        I think your event queue is filling up with events.
        
        There may be other problems, too, though.
        
        Dan

1449.2Get rid of the NoExpose eventsHANNAH::MESSENGERBob MessengerSat Sep 16 1989 18:3114
Re: .0

By default, each XCopyArea generates either a GraphicsExpose event, if part
of the source rectangle is occluded, or else a NoExpose event.  In your case
you don't have to worry about GraphicsExpose event because you are always
copying from a pixmap (which can't be occluded because it's never visible)
to a window.  You should disable exposure events in the GC used for the
XCopyAreas with:

	xgcv.graphics_exposures = False;
	XtGetGC(widg,GCForeground|GCBackground|GCGraphicsExposures,&xgcv);

				-- Bob

1449.3thanksSKYLRK::LOSCHENMon Sep 18 1989 13:0311
    Re .2
    
    And how long does one have to work with this stuff before that becomes
    intuitively obvious? 
    
    That solved the problem 100%.  I appreciate the help.  I would have
    been stumped on that one for a very long time.
    
    brent
    

1449.4I know how you feelEPIK::BUEHLERLive today, for tommorrow isn&#039;t here yetMon Sep 18 1989 18:139
>    And how long does one have to work with this stuff before that becomes
>    intuitively obvious? 
    
    Three to six months of intensive work with X will make most areas
    intuitively obvious.  DECwindows is another can of worms.
    
John
[former DECwrite developer]

1449.5PSW::WINALSKICareful with that VAX, EugeneMon Sep 18 1989 19:2412
RE: .3

One general rule of thumb in X is, always dispatch all events handed to your
application on a timely basis.  Throw away any events that your application
doesn't understand or doesn't wish to bother with.  If you do that, you don't
have to worry about things lie NoExpose events that come in from left field as
a side effect of something else you're doing.  Your code will as a matter of
course receive the event, determine that it isn't one you're interested in, and
throw it away.

--PSW