Memory Use



next up previous contents index
Next: Input and Output Up: Running Applications Previous: Group Functions

Memory Use

Tasks and pvmds allocate some memory (using malloc()) as they run. Malloc never gives memory back to the system, so the data size of each process only increases over its lifetime. Message and packet buffers (the main users of dynamic memory in PVM) are recycled, however.

The things that most commonly cause PVM to use a large amount of memory are passing huge messages, certain communication patterns and memory leaks.

A task sending a PVM message doesn't necessarily block until the corresponding receive is executed. Messages are stored at the destination until claimed, allowing some leeway when programming in PVM. The programmer should be careful to limit the number of outstanding messages. Having too many causes the receiving task (and its pvmd if the task is busy) to accumulate a lot of dynamic memory to hold all the messages.

There is nothing to stop a task from sending a message which is never claimed (because receive is never called with a wildcard pattern). This message will be held in memory until the task exits.

Make sure you're not accumulating old message buffers by moving them aside. The pvm_initsend() and receive functions automatically free the current buffer, but if you use the pvm_set[sr]buf() routines, then the associated buffers may not be freed. For example, the following code fragment allocates message buffers until the system runs out of memory:

    while (1) {
        pvm_initsend(PvmDataDefault);    /* make new buffer */
        pvm_setsbuf(0);
        /* now buffer won't be freed by next initsend */
    }

As a quick check, look at the message handles returned by initsend or receive functions. Message ids are taken from a pool, which is extended as the number of message buffers in use increases. If there is a buffer leak, message ids will start out small and increase steadily.

Two undocumented functions in libpvm dump information about message buffers: umbuf_dump(int mid, int level),
umbuf_list(int level).

Function umbuf_dump() dumps a message buffer by id (mid). Parameter level is one of:


Function umbuf_list() calls umbuf_dump() for each message in the message heap.



next up previous contents index
Next: Input and Output Up: Running Applications Previous: Group Functions