| Here is the sample code from my customer
/** ....................... **/
/** C library include files **/
/** ....................... **/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/** ......................... **/
/** DECmessageQ include files **/
/** ......................... **/
#include "p_entry.h"
#include "p_return.h"
#include "p_symbol.h"
/** ....................... **/
/** Constants **/
/** ....................... **/
#define MAX_MESSAGE_SIZE 100
/** ....................... **/
/** Function Forwards **//*
/** ....................... **/
int32 TheAttach( q_address *q_addr,
int32 q_type);
int32 ThePut( q_address *q_addr );
int32 TheGet(q_address que_to_get);
void TheExit( );
long
main( )
{
int32 dmq_status;
q_address my_primary_queue;
q_address my_secondary_queue;
q_address queue_to_talk;
printf( "\nTesting program started...\n\n" );
for (;;)
{
/* Attach to DECmessageQ */
if ( TheAttach( &my_primary_queue,
PSYM_ATTACH_PQ
) != PAMS__SUCCESS )
exit( 0 );
/* Attach to a secondary queue */
if ( TheAttach( &my_secondary_queue,
PSYM_ATTACH_SQ
) != PAMS__SUCCESS )
exit( 0 );
/* Set up the queue to talk to */
queue_to_talk.au.group = my_primary_queue.au.group;
queue_to_talk.au.queue = 8;
/* Put messages to the queue the I want to communicate
with */
dmq_status = ThePut( &queue_to_talk );
/* Get them back */
dmq_status = TheGet(my_secondary_queue);
/* Exit from DECmessageQ */
TheExit();
}
printf( "\nTest complete.\n" );
return( PAMS__SUCCESS );
} /* end of main */
int32
TheAttach( q_address *q_addr,
int32 q_type)
{
int32 attach_mode;
int32 dmq_status;
attach_mode = PSYM_ATTACH_TEMPORARY;
dmq_status = pams_attach_q(
&attach_mode,
q_addr,
&q_type,
0,
0,
(int32 *) 0, /* Use default name space */
(int32 *) 0,
(char *) 0,
(char *) 0,
(char *) 0 );
if ( dmq_status != PAMS__SUCCESS )
{
printf( "Error attaching to a temporary queue, status returned
is: %ld.\n",
dmq_status );
}
return ( dmq_status );
} /* end of TheAttach */
int32
ThePut( q_address *q_addr )
{
int i;
char priority;
char delivery;
char uma;
short msg_class;
short msg_type;
short msg_size;
int32 dmq_status;
int32 timeout;
struct PSB put_psb;
static char *MessageList[] = {
"This is the request packet for the openpath call",
"This is the aux packet for the openpath call"};
/*
** Put the messages in MessageList to the queue passed in
*/
printf( "\n" );
priority = '\0'; /* Regular priority; use 0, NOT '0'
*/
msg_class = msg_type = 0; /* No class or type at the moment
*/
delivery = PDEL_MODE_NN_MEM; /* No Notification and
nonrecoverable */
timeout = 100; /* Wait 10 seconds before giving up
*/
uma = PDEL_UMA_DISCL; /* If can't deliver it, DISCard and
Log */
for ( i = 0; i < 2; i++ )
{
msg_size = (short) strlen( MessageList[i] );
dmq_status = pams_put_msg(
MessageList[i],
&priority,
q_addr, /* passed in */
&msg_class,
&msg_type,
&delivery,
&msg_size,
&timeout,
&put_psb,
&uma,
(q_address *) 0,
(char *) 0,
(char *) 0,
(char *) 0 );
if ( dmq_status == PAMS__SUCCESS )
printf( "Put message:\t%s\n", MessageList[i] );
else
printf( "Error putting message; status returned is: %ld.\n",
dmq_status );
}/*end for */
return ( dmq_status );
} /* end of ThePut */
int32
TheGet(q_address que_to_get)
{
char priority;
short msg_class;
short msg_type;
short msg_area_len;
short msg_data_len;
int32 dmq_status;
int32 *pt_sel_filter;
char msg_area[MAX_MESSAGE_SIZE];
q_address msg_source;
struct PSB get_psb;
short sSelFilter[2];
printf( "\n" );
priority = 0; /* get messages of both high and normal
priorities */
sSelFilter [0] = que_to_get.au.queue; /* Only select messages queued
to my secondary queue */
sSelFilter [1] = PSEL_AQ;
pt_sel_filter = (int32 *)sSelFilter;
msg_area_len = MAX_MESSAGE_SIZE;
dmq_status = PAMS__SUCCESS;
while ( dmq_status == PAMS__SUCCESS )
{
/* Initialize the message area to hold the message */
memset( msg_area, '\0', MAX_MESSAGE_SIZE );
/* Get a message */
dmq_status = pams_get_msg( msg_area,
&priority,
&msg_source,
&msg_class,
&msg_type,
&msg_area_len,
&msg_data_len,
pt_sel_filter,
&get_psb,
(struct show_buffer *) 0,
(int32 *) 0,
(char *) 0,
(char *) 0,
(char *) 0 );
switch ( dmq_status )
{
case PAMS__SUCCESS :
printf( "Got message:\t\"%s\"\n", msg_area );
break;
case PAMS__NOMOREMSG :
/* Status returned when queue is empty */
break;
default :
printf( "Error getting message; status returned is %ld.\n",
dmq_status );
break;
}
}
if ( dmq_status == PAMS__NOMOREMSG )
{
dmq_status = PAMS__SUCCESS;
}
return ( dmq_status );
} /* end of TheGet */
void
TheExit( )
{
int32 dmq_status;
dmq_status = pams_exit();
if ( dmq_status == PAMS__SUCCESS )
printf( "\nExited from DECmessageQ.\n" );
else
printf( "Error exiting; status returned is %ld.\n", dmq_status );
} /* end of TheExit */
This will cause a memory leak which will continue unitl the box
crashes...
Any help would be great.
|
| Hello Pat,
Thanks for helping us out with the call. I have a response fromthe
customer.
Here are answers to your questions:
o How are they observing the leak?
We use both PView and Windows NT Performace Monitor. They both
indicate
the virtual bytes going
up when the test program is running. The dmqcls initially uses
appox. 12Mb
of virtual memory.
Several times when it eventually reaches 545Mb, the dmqcls hangs.
However,
one time the dmqcls
hangs when its virtual memory reaches 82 Mb.
o How fast does the memory appear to leak?
I can't tell it leaks at a constant rate. Initially it is doubled
in 5
minutes (from 12Mb to 25Mb).
It goes up to 35Mb in 30 minutes. It would stay at certain level
for a
while, then jumps up
another 10Mb.
o Are they running the test locally on the NT box, or remotely on a
client
machine? If the app is running remotely, which DECmessageQ client
are they
using ( Windows 3.1/95/NT, or UNIX )?
We are running the test locally on the NT box.
You should be able to run the test problem on your machine, and see for
yourself how virtual memory gets eaten up, and finally the dmqcls
hangs.
|