Memory Leak warning if you use *Cstring parameters

Tags: #<Tag:0x00007f46e4861398> #<Tag:0x00007f46e4861028>


TIP: Clarion 11 and earlier.
PTSS: 42786 (visible, and has example program)

Passing a *Cstring into a Procedure or Method, then doing an empty CASE on the parameter results in a memory leak.

Proc1  procedure(*cstring pName) ! change type to anything else, no leak
  case pName           ! remove the empty CASE statement, no leak

The above code leaks the length of the pName parameter.


Hi Bruce,

To be fair the Help states that the OF clause is mandatory…

CASE condition
OF expression [ TO expression ]
[ OROF expression [ TO expression ] ]
[ ELSE ]

the OROF TO and ELSE clauses can be omitted - but not the OF



True, but then it’s not a compiler leak error, it’s a compiler syntax-error error :slight_smile:


Hi Bruce,

I reported a memory leak to SV a few years ago related to the CASE statement.

I found that some template generated code could under certain circumstances generate a CASE structure without any “OF” statements (depending on user template input). In this scenario the leak occurred - it seems its never been addressed :frowning:




yes, same thing as I found, but only if parameter is a *CSTRING and only if the CASE is on that Parameter. Do you have a PTSS reference for it?


I took a look earlier for the PTSS number but can’t find it? I could have swore I raised it on that system - maybe it was a direct email? I know I also raised it on the usergroups too - just so others could be made aware of it and work around accordingly…

In my tests, I don’t think it was related to a parameter, just a straight forward CASE END (without any OF statements) - I seem to remember 4k leaking??


It’s very specific now - has to be CASE Parameter, and the Parameter has to be a *Cstring. Leaks the size of the parameter string. So maybe yours was fixed, but this is an edge case…


That’s good news if it is fixed. It was quite a while ago - maybe as far back as C8 / C9

Cheers, Andy