memory allocation in postgres

Поиск
Список
Период
Сортировка
От Kjetil Haaland
Тема memory allocation in postgres
Дата
Msg-id 200411221428.47825.kjetil.haaland@student.uib.no
обсуждение исходный текст
Ответы Re: memory allocation in postgres
Список pgsql-novice
Hello all

I have written my own type and a some functions to use in postgres, but i have
some problems with the memory allocation. In one of the functions, the stuff
that is inserted is supposed to last until the user logs out, so i have
changed the memorycontext  to TopMemoryContext like this:
  MemoryContext oldcontext;
  oldcontext = MemoryContextSwitchTo(TopMemoryContext);

and back when the function is done
  MemoryContextSwitchTo(oldcontext);

The problem is, when i allocate memory in some of the other functions it is
null the first time i call it, and thats correct, but the next time i call
the same function, what was inserted in the last round is still there. Is
there away to delete it when the function is finished? I have allocated the
memory like this:
  char *res1 = NULL;
  char *res2 = NULL;
  res1 = (char *) palloc((inlength+smllength)*sizeof(char));
  res2 = (char *) palloc((inlength+smllength)*sizeof(char));

and then tried to free it in the end (i have read that you don't have to do
this but i tried it anyway, but it didn't help)
   pfree(res1);
   pfree(res2);

Hope someone can help
Regards,
Kjetil

В списке pgsql-novice по дате отправления:

Предыдущее
От: "Alberto Viglione Tiscali"
Дата:
Сообщение: unsubscribe
Следующее
От: Tom Lane
Дата:
Сообщение: Re: memory allocation in postgres