[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

2004.0. "DecWindows Pascal binding loses memory, C binding doesn't" by XLIB::JACKSON (Collis Jackson) Fri Jan 05 1990 15:30

We have customer with a problem with simple text widgets releasing memory 
allocated for their strings using the VMS binding.  The following program 
in C maintains a constant virtual page count once it gets up and running.
Its Pascal counterpart is included below.  Over time, its virtual page
count grows without bound.  How can we get the simple text widget to let
go of its memory allocated to hold strings in the Pascal example?

We have reproduced the problem under VMS 5.3 (with DecWindows 2.0).  Is
this a bug with the bindings?  Is there some way (using the same bindings)
to work around this?  

			Thanks,  

			Collis Jackson

#include <stdio.h>
#include <decw$include/DECwDwtApplProg.h>

#define applicationName         "memstr"
#define applicationClass        "Demo"

static char *s;
static Widget top_level, DB, S;
Arg args[1];

main(argc,argv)
   unsigned int argc;
   char *argv[];
{
   s = "The String\0";
   top_level = XtInitialize(applicationName,applicationClass,
                            NULL,0,                /* no options */
                            &argc,argv);
   DB = DwtDialogBoxCreate (top_level, applicationClass, args, 0);
   S = DwtSTextCreate (DB, applicationClass, args, 0);
   XtManageChild(S);
   XtManageChild(DB);
   XtRealizeWidget(top_level);

   proc();

   XtMainLoop();
}

proc ()
{
    int x;

    XtAddTimeOut (10, proc, NULL);

    for (x = 0; x < 100; x++) {
	DwtSTextSetString (S, s);
    }
}
    
    ----------
    
[INHERIT ('SYS$LIBRARY:DECW$DWTDEF')]
program mem;
TYPE
	$DEFPTR	= ^INTEGER;
VAR
	Ptr	: $DEFPTR;
	T,DB,S	: Dwt$Widget;
	argc: Dwt$Cardinal := 0;
	Arglist	: ARRAY [1..1] OF Dwt$Arg;
	TheString : PACKED ARRAY [1..11] OF CHAR := 'The String'(0);

PROCEDURE Proc;
VAR
	ProcAddr: [static] Dwt$Timer_Callback_Proc;
	x : INTEGER;
BEGIN
	ProcAddr::INTEGER := IADDRESS (Proc);
	XT$ADD_TIME_OUT (10, ProcAddr, %IMMED 0);

	FOR x := 1 TO 100 DO
		DWT$S_TEXT_SET_STRING (S, TheString);
END;

BEGIN
	T := XT$INITIALIZE ('MEM','mem',0,0,argc);
	DB := DWT$DIALOG_BOX_CREATE (T, 'DB', Arglist, 0);
	S := DWT$S_TEXT_CREATE (DB, 'S', Arglist, 0);
	XT$MANAGE_CHILD (S);
	XT$MANAGE_CHILD (DB);
	XT$REALIZE_WIDGET (T);

	Proc;
	XT$MAIN_LOOP;
END.
    
T.RTitleUserPersonal
Name
DateLines
2004.1QUARK::LIONELFree advice is worth every centTue Jan 09 1990 11:5614
I won't ask why your program sets the same text in the widget over and over...

There are lots of problems like this in the "VAX bindings".  What happens is
that the routine you call needs to convert the string you passed by
descriptor to an ASCIZ string before calling the "real" routine.  It does
this by allocating virtual memory for the ASCIZ copy.  It should deallocate
that copy before returning.  Not all the routines do.

This is a bug and should be SPRed (since it is a customer report).  Suggest
that other similar VAX binding routines be examined for similar problems.

The only workaround I can suggest is to call the C binding directly.

				Steve
2004.2ThanksXLIB::JACKSONCollis JacksonTue Jan 09 1990 16:388
Thanks for the response.

The programs I included were only intended to be test programs demonstrating
the problem (not the customer's application!)

We will submit a bug report.

Collis Jackson
2004.3Did it get SPR'd? Workaround?PEACHS::BELDINWed Jun 13 1990 18:156

	Did this get SPR'd?  Which database?  Is there a workaround?

	Rick Beldin
	Atlanta CSC