If I allocate a linked list, then free the whole list nodes one by one,
it seems that under Linux, only after the whole list is freed, the 'SZ'
field of 'ps' command is resumed to the level before the list is created.
Even if only one node is left, the 'SZ' field is not any different than
the whole list is there. Under Solaris, even if the whole list is freed,
the 'SZ' field does not resume. Follwoing is my test program:
Anyone knows why?
-------------------------------> test.c <---------------------
#include <stdio.h>
#define SIZE 9000
typedef struct node_cell *pNode;
typedef struct node_cell {
int dumy;
int dumy2;
pNode next;
main()Quote:} Node;
{
int i;
Node *head, *test, *new;
system("ps u | grep a.out");
test = (Node *) malloc(sizeof(Node));
head = test;
for(i=0; i<SIZE; i++)
{
new = (Node *) malloc(sizeof(Node));
test->next = new;
test = new;
}
new->next = 0;
system("ps u | grep a.out");
i=0;
while(head)
{
i++;
new = head;
head = head->next;
free(new);
if(i== SIZE)
system("ps u | grep a.out");
}
system("ps u | grep a.out");
Quote:}