Re: c-client IMAP API and memory

2002-12-10 Thread Shawn Walker
On 12/10/2002 at 11:11 AM Mark Crispin wrote:
>On Tue, 10 Dec 2002, Shawn Walker wrote:
>> That is the "problem".  I have had several customers running low on
>> resources when the application was downloading a very large INBOX folder
>> (the folder contains several thousands messages with very large messages
>> that contains attachments).
>
>Why is the application "downloading"?  Are you using IMAP like IMAP, or
>like a fancy POP?
>
>The c-client library is intended to be used for interactive access, and
>not really for POP-like "downloading".
>
>-- Mark --
>

The user selected to download all messages and body.  So, that is what the
app is doing.  The users do that to do "off-line" mode.  But, cclient is
still hold the messages, even if the user manually select each message to
read, cclient cache them.  How to get cclient to free the memories?

Shawn





Re: c-client IMAP API and memory

2002-12-10 Thread Mark Crispin
On Tue, 10 Dec 2002, Shawn Walker wrote:
> That is the "problem".  I have had several customers running low on
> resources when the application was downloading a very large INBOX folder
> (the folder contains several thousands messages with very large messages
> that contains attachments).

Why is the application "downloading"?  Are you using IMAP like IMAP, or
like a fancy POP?

The c-client library is intended to be used for interactive access, and
not really for POP-like "downloading".

-- Mark --

http://staff.washington.edu/mrc
Science does not emerge from voting, party politics, or public debate.



Re: c-client IMAP API and memory

2002-12-10 Thread Shawn Walker
On 12/10/2002 at 10:47 AM Mark Crispin wrote:
>On Tue, 10 Dec 2002, Shawn Walker wrote:
>> Then how does one get cclient to free the memory after it retrieve a
VERY
>> large message from the server?  I debugged into cclient saw how the
>message
>> is being stored in memory and how to free it and the only way was to run
>> the garbage collector.
>
>What do you mean by "VERY large"?
>
>Whenever you run the garbage collector, you destroy the entire cache,
>which means that c-client is forced to re-fetch any data that it needs
>again.  Unless you mean at least "tens of megabytes" by "VERY large", you
>are causing more harm than good by doing so.
>
>And even if it is that big, what if the user references it again?
>
>Note that when you expunge a message, any cache associated with that
>message is freed.
>
>Memory is cheap.  Use it.
>
>-- Mark --

That is the "problem".  I have had several customers running low on
resources when the application was downloading a very large INBOX folder
(the folder contains several thousands messages with very large messages
that contains attachments).  The user was getting memory getting low on the
windows machine.  I was able to recreate the problem what the customers was
having and it was a problem.  I had to get cclient to free the memory to
keep that from happening.

Shawn





Re: c-client IMAP API and memory

2002-12-10 Thread Mark Crispin
On Tue, 10 Dec 2002, Shawn Walker wrote:
> Then how does one get cclient to free the memory after it retrieve a VERY
> large message from the server?  I debugged into cclient saw how the message
> is being stored in memory and how to free it and the only way was to run
> the garbage collector.

What do you mean by "VERY large"?

Whenever you run the garbage collector, you destroy the entire cache,
which means that c-client is forced to re-fetch any data that it needs
again.  Unless you mean at least "tens of megabytes" by "VERY large", you
are causing more harm than good by doing so.

And even if it is that big, what if the user references it again?

Note that when you expunge a message, any cache associated with that
message is freed.

Memory is cheap.  Use it.

-- Mark --

http://staff.washington.edu/mrc
Science does not emerge from voting, party politics, or public debate.



Re: c-client IMAP API and memory

2002-12-10 Thread Shawn Walker
On 12/10/2002 at 10:40 AM Mark Crispin wrote:
>On Tue, 10 Dec 2002, Shawn Walker wrote:
>> You need to run the garbage collector to get the cclient to free the
>> memory.  To do the following code after you call mail_fetchbody_full().
>> mail_parameters(MailStream, SET_GETS, nil);
>> mail_gc(MailStream, GC_TEXTS);
>
>This is an extremely BAD idea, unless of course you like writing
>applications which are slow and waste network bandwidth.
>
>c-client caches for a reason.  The only justification for using mail_gc()
>is if you are writing a program for DOS, 16-bit Windows (Windows 3.x), or
>old Macintosh systems.  It should never be used on modern systems except
>in extreme circumstances; and certainly should not be used routinely.
>
>-- Mark --
>

Then how does one get cclient to free the memory after it retrieve a VERY
large message from the server?  I debugged into cclient saw how the message
is being stored in memory and how to free it and the only way was to run
the garbage collector.

Shawn





Re: c-client IMAP API and memory

2002-12-10 Thread Mark Crispin
On Tue, 10 Dec 2002, Shawn Walker wrote:
> You need to run the garbage collector to get the cclient to free the
> memory.  To do the following code after you call mail_fetchbody_full().
> mail_parameters(MailStream, SET_GETS, nil);
> mail_gc(MailStream, GC_TEXTS);

This is an extremely BAD idea, unless of course you like writing
applications which are slow and waste network bandwidth.

c-client caches for a reason.  The only justification for using mail_gc()
is if you are writing a program for DOS, 16-bit Windows (Windows 3.x), or
old Macintosh systems.  It should never be used on modern systems except
in extreme circumstances; and certainly should not be used routinely.

-- Mark --

http://staff.washington.edu/mrc
Science does not emerge from voting, party politics, or public debate.



Re: c-client IMAP API and memory

2002-12-10 Thread Mark Crispin
On Tue, 10 Dec 2002, Guillaume Vaillant wrote:
> I use for example  the mail_fetchbody_full function which return a (char *)
> data.
> I want to know if I have to free this pointed memory or not ?

You do not need to free any memory returned by any mail_???() function;
and in fact you must not free such memory.

The only memory that you ever need to free in c-client is memory from
certain calls that are documented to create memory, most notably cpystr(),
rfc822_binary(), rfc822_base64(), rfc822_8bit(), and rfc822_qprint().

-- Mark --

http://staff.washington.edu/mrc
Science does not emerge from voting, party politics, or public debate.



Re: c-client IMAP API and memory

2002-12-10 Thread Shawn Walker
Hello,

You need to run the garbage collector to get the cclient to free the
memory.  To do the following code after you call mail_fetchbody_full().

// Run the garbage collection to free up memory in cclient

mail_parameters(MailStream, SET_GETS, nil);
mail_gc(MailStream, GC_TEXTS);

On 12/10/2002 at 7:12 PM Guillaume Vaillant wrote:

>Hello,
>I'm a new user of the c-client API and I need help to manage memory leaks
>on
>my application.
>I use for example  the mail_fetchbody_full function which return a (char
*)
>data.
>I want to know if I have to free this pointed memory or not ?
>
>It's not the only one function for which i don't know who free the memory.
>Where can i find help about that point
>Does someone can help me ?
>
>Thank's
>Guyom
>
>-- 
>--
> For information about this mailing list, and its archives, see: 
> http://www.washington.edu/imap/c-client-list.html
>--