Operating System - OpenVMS
1748176 Members
4096 Online
108758 Solutions
New Discussion юеВ

Re: Problem with STR$CONCAT

 
Not applicable

Problem with STR$CONCAT

Hi,

We have a code for a product written in C.
A process make use of str$concat function to concatenate two strings.
Now when we are running that process it successfully doing the job for the first time but second time when we are doing it, its giving the following error:

STR$_INSVIRMEM

I already have OpenVMS RTL String Manipulation (STR$) Manual but I didn't find anything useful in it.

Could anyone help me to know why we got this error and why the process is running fine first time but giving problem second time.

Note: In the code we are trying to concatenate strings of very large length.

Best Regards,
ajaydec
18 REPLIES 18
Steven Schweda
Honored Contributor

Re: Problem with STR$CONCAT

> We have a code for a product written in C.

Perhaps so, but we can't see it. I can't
speak for others, but my psychic powers are
weak.

> Could anyone help me [...]

I don't see how.

> [...] strings of very large length.

How large is "very large"? 256? 2G?

You are using descriptors, right?
Hein van den Heuvel
Honored Contributor

Re: Problem with STR$CONCAT

STR$CONCAT requires descriptors.
Those are not native to C.
You can all too easily get them wrong.
Since you can do it once, the program must get it 'mostly' right. Still...

How does the product create the descriptors?

How large is a piece of string?
'very large' is NOT good enough as answer.
Magic numbers to think about: 32KB (2**15), 64KB (2**16).

Mind you... concatenating big pieces of string suggest 'sup-optimal' programming.

hth,
Hein.
Not applicable

Re: Problem with STR$CONCAT

String size is more than 256 kb.
I want to know under what circumstances str$concat function can generate INSVIRMEM signal.

We are using extended descriptor as the destination and a character strings for source strings.

Best Regards,
ajaydec
Wim Van den Wyngaert
Honored Contributor

Re: Problem with STR$CONCAT

Help/mes/fac=str insvirmem

(just learned the /facility qualifier exist)

May be increase user quota pgflquo.

Wim
Wim
Jon Pinkley
Honored Contributor

Re: Problem with STR$CONCAT

RE:"I already have OpenVMS RTL String Manipulation (STR$) Manual but I didn't find anything useful in it."

Did you look at the end of the STR$CONCAT section?

STR$_INSVIRMEM Insufficient virtual memory. STR$CONCAT could not allocate heap storage for a dynamic or temporary string.

What you are asking the service to do is to take multiple input strings and create a new one from contiguous virtual address space. The system needs a place to put this copy. It allocates memory, copies your strings together, and returns the address of this new string in the descriptor.

If you are never freeing the memory used by these strings, the space they occupy will not be available for other strings. Even if you do free it, the pool will become fragmented if resultant string size is not a constant size, or if you are creating other strings in the pool. In this respect it is like fragmentation on a disks, and the diminishing size of the largest contiguous file that can be created on the disk.

Please skim chapter 1 and read chapter 2 of the STR$ manual.

Although the following thread isn't exactly related to your question, it discusses the underlying cause of the pool fragmentation:

http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=1198013

If you have plenty of memory, and privilege, you can increase your pgflquota and you will then be able to consume more resources before the system tells refuses to give you more.

Jon
it depends
Willem Grooters
Honored Contributor

Re: Problem with STR$CONCAT

Is the second call additional to the first?
I mean:

1: Concatenate A + B ==> Z
2: Concatenate C + Z ==> Y
(so Y = A + B + C)

of is the second one the same as the first with new variable content?

Is it possible that your strings are dynamic (requirement for STR$CONCAT), perhaps created with STR$GET1_DX? It could help if you did a STR$FREE1_DX first, to release allocated memory.

INSVIRMEM means you run out of virtual memory. Increasing PGFLQUOTA may help in that case.
Willem Grooters
OpenVMS Developer & System Manager
Not applicable

Re: Problem with STR$CONCAT

Yes, I am doing the following:
Is the second call additional to the first?
I mean:
1: Concatenate A + B ==> Z
2: Concatenate C + Z ==> Y
(so Y = A + B + C)
of is the second one the same as the first with new variable content?

And I am using lib$sfree1_dd to free the allocated memor.
Jon Pinkley
Honored Contributor

Re: Problem with STR$CONCAT

If you interested only in the A + B + C string and not the intermediate A + B string, then why not call STR$CONCAT with more than two arguments? The following is from the manual.

STR$CONCAT

The Concatenate Two or More Strings routine concatenates all specified source strings into a single destination string.

Format
STR$CONCAT destination-string ,source-string [,source-string...]

There really is useful information in the manual whether you found it or not. It does not seem you looked very hard.
it depends
Hein van den Heuvel
Honored Contributor

Re: Problem with STR$CONCAT

Ajadec,

So the program is using and building a 64 bit descriptor and using :
DSC64$Q_LENGTH / DSC64$PQ_POINTER

OS version / Platform?

Or are strings A + B possibly less than 64K in length and A + B + C > 64K?

I still suspect that concattenating large strigns is poor / lazy programig, but of course it may well be the optimal solution.


As others replied, INSVIRMEM suggest the program is out or PAGFILQUO.
Did you check?
Try: $SHOW PROC/CONT ... 'q'

Cheers,
Hein.