Memory Leak warning if you use *Cstring parameters

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

#1

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.
eg

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

The above code leaks the length of the pName parameter.


#2

Hi Bruce,

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

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

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

Graham


#4

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


#5

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:

Regards,

Andy


#6

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?


#7

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??


#8

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…


#9

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

Cheers, Andy