Panagiotis Sidiropoulos schreef:
I think I found the cause of the problem, hope not to change it’s mind :-).

I had a pchar var used as this:

var pName: pchar;
begin
     <some process>
     getmem( pName, nSizeNeeded );
     <some process>
     freemem( pName );
     <some process>
end;

The exact processing code was:

GetMem( lpLocalBuffer, length( strBuffer ) );
StrPCopy( lpLocalBuffer, strBuffer );
TopicMemoryStream.Clear;
TopicMemoryStream.WriteBuffer( lpLocalBuffer^, length( lpLocalBuffer ) ); 
TopicMemoryStream.Position := 0; FreeMem( lpLocalBuffer );

- lpLocalBuffer is pchar var declared in var section of the function.
- strbuffer is a String.
- TopicMemoryStream is a TMemoryStream.

In simple words, I used pchar var only when needed and freed when done. This 
function is called very often. Noticing that debugger displayed this specific 
unit in most of SIGSEGV cases and this was only the case of memory allocation 
by my self, I decided to declare it as a global var, allocate memory on form 
creation and free it on form destroy. Now it is more stable. There are rare 
ocassions of error messages but I will try to investigate it. Thanks a lot for 
your support.

If my code is OK then Lazarus and FPC gurus may find this interesting for 
investigation.


Did you try running your code with heaptrc (-gh option in the linking tab).

I suspect that you allocate one byte less than needed (1 extra for the terminating #0 of pchars).

Vincent

_________________________________________________________________
    To unsubscribe: mail [EMAIL PROTECTED] with
               "unsubscribe" as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to