Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2008-06

Problem with threads and cwstrings

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Alexander Bauer

Hi,

i have a problem when i use cwstrings together with threads on linux.

I made a simple program which create threads in an endless loop. Every thread only does a sleep(1) and then finish.

Without 'cwstrings' everything works fine.
But when i include 'cwstrings' the program eats more and more memory.

What is the problem ?

FPC 2.2.1 (I also tested with FPC 2.3.1) with Ubuntu 8.04

Alex

---------------------------------------------------------------------------------- threaddemo.lpr
---------------------------------------------------------------------------------- program threaddemo;

{$mode objfpc}{$H+}

uses
cthreads,
cwstring,
SysUtils,

  mythread;
var
  i: integer;
  bTerm: boolean;
  Thread: TmyThread;
begin
  i := 0;
  bTerm := false;
  while not bTerm do
  begin
    Thread := TmyThread.create(true);
    Thread.Resume;
    Inc(i);
    Sleep(1);
    WriteLn('Thread #' + IntToStr(i));
  end;
  Halt(0);
end.

---------------------------------------------------------------------------------- mythread.pas
---------------------------------------------------------------------------------- unit mythread;

interface
uses
  Classes, SysUtils;
type
  TmyThread = class(TThread)
  private
  public
    Constructor Create(CreateSuspended : boolean);
    procedure Execute; override;
  end;
implementation

{ TmyThread }

Constructor TmyThread.Create(CreateSuspended : boolean);
begin
  inherited create(CreateSuspended);
  FreeOnTerminate:=true;
end;
procedure TmyThread.Execute;
begin
  sleep(1);
end;
end.
Jonas Maebe
to Alexander Bauer
Alexander Bauer wrote 9 lines
i have a problem when i use cwstrings together with threads on linux. I made a simple program which create threads in an endless loop. Every thread only does a sleep(1) and then finish. Without 'cwstrings' everything works fine. But when i include 'cwstrings' the program eats more and more memory. What is the problem ?

Please submit a bug report.

Jonas