How To free resources used by large object Relations?
Hi,
I've changed the large object memory managment strategy to ensure that
each large object has it's own memory context.
This way I can free all memory for a large object when I lo_close
is called for it's oid. This seems to work.
I've noticed that the heap_close function used to close the heap used
by a large object doesn't really do any thing. (It calls RelationClose
which decrements some reference count).
Somehow I have to free the relation from the cache in the following
situations:
1. In a transaction I must free the stuff when the transaction is
commited/aborted.
2. Otherwise it must happen when lo_close is called.
Is this right?
Can anyone point me in the right direction?
Thanks Maurice.
Hi,
I've changed the large object memory managment strategy to ensure that
each large object has it's own memory context.
This way I can free all memory for a large object when I lo_close
is called for it's oid. This seems to work.
This is a good idea.
I've noticed that the heap_close function used to close the heap used
by a large object doesn't really do any thing. (It calls RelationClose
which decrements some reference count).Somehow I have to free the relation from the cache in the following
situations:
1. In a transaction I must free the stuff when the transaction is
commited/aborted.
2. Otherwise it must happen when lo_close is called.Is this right?
Beats me.
--
Bruce Momjian
maillist@candle.pha.pa.us
Maurice Gittens wrote:
Hi,
I've changed the large object memory managment strategy to ensure that
each large object has it's own memory context.
This way I can free all memory for a large object when I lo_close
is called for it's oid. This seems to work.I've noticed that the heap_close function used to close the heap used
by a large object doesn't really do any thing. (It calls RelationClose
which decrements some reference count).Somehow I have to free the relation from the cache in the following
situations:
1. In a transaction I must free the stuff when the transaction is
commited/aborted.
Backend does it, don't worry.
2. Otherwise it must happen when lo_close is called.
It seems that you can't remove relation from cache untill
commit/abort, currently: backend uses local cache to unlink
files of relations created in transaction if abort...
We could change relcache.c:RelationPurgeLocalRelation()
to read from pg_class directly...
But how many LO do you create in single xact ?
Is memory allocated for cache so big ?
Vadim
-----Original Message-----
From: Vadim B. Mikheev <vadim@sable.krasnoyarsk.su>
To: Maurice Gittens <mgittens@gits.nl>
Cc: pgsql-hackers@postgreSQL.org <pgsql-hackers@postgreSQL.org>
Date: zondag 22 februari 1998 17:47
Subject: Re: [HACKERS] How To free resources used by large object Relations?
Somehow I have to free the relation from the cache in the following
situations:
1. In a transaction I must free the stuff when the transaction is
commited/aborted.Backend does it, don't worry.
I don't really understand all of the code so please bear with me.
Could it be that large objects don't use the right memorycontext/portals so
that memory isn't freed automagically?
2. Otherwise it must happen when lo_close is called.
It seems that you can't remove relation from cache untill
commit/abort, currently: backend uses local cache to unlink
files of relations created in transaction if abort...
We could change relcache.c:RelationPurgeLocalRelation()
to read from pg_class directly...
Is there a way to to tell the cache manager to free resources?
The relations concerned are know how to properly free them is not
however.
But how many LO do you create in single xact ?
Only one (in my real application).
Is memory allocated for cache so big ?
Not really except that the leak accumulates as long as the connection
with the backend is not closed.
Vadim
I have a simple test program which goes like this:
(this is C-like psuedo code)
main()
{
connection = createConnection();
for(;;)
{
lo_create(connection,READ|WRITE);
}
destroyConnection(connection);
}
This program will leak memory each time it goes through the for loop.
It doesn't matter if the statements in the for loop are in a transaction or
not.
When I give each large object it's own memory context (so that memory
is freed per large object) it seems to leak memory more slowly, but it leaks
anyway.
I've tried calling a number of the functions (like
RelationPurgeLocalRelation)
in relcache.c to try to free up the memory myself but the backend doesn't
like
this (== closed connection).
It looks like there is some assumption about which memorycontext/portal is
used during transactions and that largeobjects don't obey this
assumption.
Can you make these assumptions explicite? Maybe I can then let
large object respect these rules.
Now I have the following understanding of these matters:
1. In transactions
All memory should be freed automatically at commit/abort.
How do I tell the system to do it for me?
2. In autocommit mode
All resources used by large object should be freed at lo_close.
Can I have this delayed and done automatically in the CommitTransaction
function?
3. Somehow atomic functions like lo_create should not leak memory either.
This is the case however.
Thanks for any help,
Maurice
Import Notes
Resolved by subject fallback
I'm sorry, Maurice, but I haven't time to deal with this now.
Let's 6.3 be out first...
Vadim
-----Original Message-----
From: Vadim B. Mikheev <vadim@sable.krasnoyarsk.su>
To: Maurice Gittens <mgittens@gits.nl>
Cc: pgsql-hackers@postgreSQL.org <pgsql-hackers@postgreSQL.org>
Date: dinsdag 24 februari 1998 10:01
Subject: Re: [HACKERS] How To free resources used by large object Relations?
I'm sorry, Maurice, but I haven't time to deal with this now.
Let's 6.3 be out first...Vadim
No problem. Let's make a stable 6.3.
Regards,
Maurice
Import Notes
Resolved by subject fallback