[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [CPROG] memory mangement - leak forbyggelse.



Michael Nielsen <sslug@sslug> skrev:

> Da, i et andet multithreaded program, benytter jeg både
> gethostbyname, og strerror, og mpatrol rapportere at disse kald
> leaker hukkomelse, og der er et mindre memory leak i programmet.

Begge disse funktioner returnerer pegere til buffere, de selv
håndterer. Du skal således ikke frigive noget, men til gengæld er
pegerne kun gyldige indtil du kalder funktionen næste gang.

Det er da muligt, at der kommer et lille leak første gang de bruges;
det har jeg ikke undersøgt. I givet fald vil det ikke akkumulere ved
gentagen brug, og er således næppe noget problem.

Et problem er det dog at bruge globale variable (som disse pointere
reelt er) i flertrådede programmer. Du skal derfor nok finde nye
versioner, hvor der ikke bruges globale variable. De hedder vist nok
gethostbyname_r() og strerror_r() men jeg kan faktisk ikke finde "man"
sider om dem på mit eget system lige nu :-(.




Anders.


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:09 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *