Re: Files & Garbage Collector

From: [at]} <Gérard>
Date: Mon, 18 Oct 2004 23:41:47 +0200

----boundary-LibPST-iamunique-1390314007_-_-
Content-type: text/plain

> Hmm,
>
> strange enough:
>
> MODULE PrivTest;
> IMPORT Out, Kernel;
>
> PROCEDURE Do*;
> BEGIN
> Out.String ("Allocated: ");
> Out.Int(Kernel.Allocated(),0);
> Out.Ln
> END Do;
>
> END PrivTest.Do
>
> gives with repeated calls also increasing values.
> Allocated: 373936
> Allocated: 377008
> Allocated: 380080
> Allocated: 383152
> Allocated: 386224
> Allocated: 389296
> Allocated: 392368
> Allocated: 395440
> Allocated: 398512
> Allocated: 401584
> Allocated: 404656
> Allocated: 407728
> Allocated: 410800
> Allocated: 413872
> Allocated: 416944
> Allocated: 420016
> Allocated: 423088

Well, in this case it's rather unsurprising for two reasons:

    - the garbage collector doesn't start running at every allocation;
    - every call to an Out procedure allocates something on the heap (to
fill the Log), and increases allocated memory. It's why I used
Dialog.ShowStatus in my last example instead of Out or StdLog.

But, if you allocate repeatedly the same pointer variable, you'll see
allocated memory increase, and sometimes decrease when GC starts running,
with its mean value remaining stable. For example, you can try:

MODULE PrivTest2;
IMPORT Dialog, Kernel, Services, Strings;

PROCEDURE Do*;
CONST
delay = ENTIER(0.01 * Services.resolution);
VAR
s: ARRAY 12 OF CHAR;
a:POINTER TO ARRAY 1024 OF BYTE;
t: LONGINT;
BEGIN
LOOP
NEW(a);
Strings.IntToString(Kernel.Allocated(), s);
Dialog.ShowStatus(s);
t := Services.Ticks() + delay;
REPEAT
UNTIL Services.Ticks() > t;
END;
END Do;

END PrivTest2.

Cheers.
Grard

--------------------------------------------

To unsubscribe from this mailing list, send a message containing the word "unsubscribe" to:
   blackbox-request{([at]})nowhere.xy

To get a list of valid e-mail commands and instructions on their usage, send a message containing the word "help" to the above address.

Send any problem reports or questions related to this email list to the list owner at
   owner-blackbox{([at]})nowhere.xy

Current posting policy:

a) To post you should use the same address by which you are subscribed to the mailing list. That way, the list server will recognize you as subscriber and forward your posting immediately, without creating any overhead.

b) If, for some reason, you cannot post from the address, by which you are subscribed, your message will be moderated to avoid spam. Please understand that moderation will often cause some delay, in particular over weekends or holydays.


----boundary-LibPST-iamunique-1390314007_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"

e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzc1xmY2hhcnNldDAgQXJpYWw7fQ0Ke1xmMVxmbW9kZXJuIENvdXJpZXIgTmV3O30NCntcZjJc
Zm5pbFxmY2hhcnNldDIgU3ltYm9sO30NCntcZjNcZm1vZGVyblxmY2hhcnNldDAgQ291cmllciBO
ZXc7fX0NCntcY29sb3J0YmxccmVkMFxncmVlbjBcYmx1ZTA7XHJlZDBcZ3JlZW4wXGJsdWUyNTU7
fQ0KXHVjMVxwYXJkXHBsYWluXGRlZnRhYjM2MCBcZjBcZnMyMCA+IEhtbSxccGFyDQo+XHBhcg0K
PiBzdHJhbmdlIGVub3VnaDpccGFyDQo+XHBhcg0KPiBNT0RVTEUgUHJpdlRlc3Q7XHBhcg0KPiAg
IElNUE9SVCBPdXQsIEtlcm5lbDtccGFyDQo+XHBhcg0KPiAgICBQUk9DRURVUkUgRG8qO1xwYXIN
Cj4gICAgICAgQkVHSU5ccGFyDQo+ICAgICAgICAgICAgT3V0LlN0cmluZyAoIkFsbG9jYXRlZDog
Iik7XHBhcg0KPiAgICAgICAgICAgIE91dC5JbnQoS2VybmVsLkFsbG9jYXRlZCgpLDApO1xwYXIN
Cj4gICAgICAgICAgICBPdXQuTG5ccGFyDQo+ICAgICBFTkQgRG87XHBhcg0KPlxwYXINCj4gRU5E
IFByaXZUZXN0LkRvXHBhcg0KPlxwYXINCj4gZ2l2ZXMgd2l0aCByZXBlYXRlZCBjYWxscyBhbHNv
ICBpbmNyZWFzaW5nIHZhbHVlcy5ccGFyDQo+IEFsbG9jYXRlZ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dXIgbWVzc2FnZSB3aWxsIGJlIG1vZGVyYXRlZCB0byBhdm9pZCBzcGFtLiBQ
bGVhc2UgdW5kZXJzdGFuZCB0aGF0IG1vZGVyYXRpb24gd2lsbCBvZnRlbiBjYXVzZSBzb21lIGRl
bGF5LCBpbiBwYXJ0aWN1bGFyIG92ZXIgd2Vla2VuZHMgb3IgaG9seWRheXMuXHBhcg0KfQ=


----boundary-LibPST-iamunique-1390314007_-_---
Received on Mon Oct 18 2004 - 23:41:47 UTC

This archive was generated by hypermail 2.3.0 : Thu Sep 26 2013 - 06:28:33 UTC