nanogui: Server don't free memory from images after releasing it with GrFreeImage


Previous by date: 21 Oct 2005 06:23:32 +0100 Re: Multiline text, Greg Haerr
Next by date: 21 Oct 2005 06:23:32 +0100 Asian Fonts In Nano-X, Gil Glass
Previous in thread: 21 Oct 2005 06:23:32 +0100 Server don't free memory from images after releasing it with GrFreeImage, Michael Augst
Next in thread:

Subject: Re: [nanogui] Server don't free memory from images after releasing it with GrFreeImage
From: "Greg Haerr" ####@####.####
Date: 21 Oct 2005 06:23:32 +0100
Message-Id: <04a301c5d5fd$70b1a660$6401a8c0@winXP>

I don't think we have server memory leaks in the
image code, but there's always room for more bugs :)

Have you checked your code to make sure that there
is in fact a FreeImage for every LoadImage?  You
might also try GrClose(), disconnecting the client,
this will cause the server to free all data associated
with the client, and thus you could compare memory
usage before and after that time.

Regards,

Greg



: For loading a images i created the nxImage class.
: It works fine with many accesses and often switching the images,
: but after loading and unloading the background (320x240) and
: switching to a icon 32x32 the used memory by the server stays
: the same. After this i can load the background again without
: any changing of the used memory by the server.
: Meanwile i have about 20 icons and used memory goes up at the
: beginning from 2400 Kb (no images) to 2700 Kb (full 24 icons +
: background) but never decreases even the progamm is running
: in a part with only 4 icons (the max are 20 in a selectionmenu).
: By the way the backgroundimage (320x240) is allways present and
: in the beginning of the programm the 4 icon menu + background
: takes only 2600 Kb of memory.
: As you can see in the code i unload the image before i load a
: new one and i allways free the last image after im finished the
: drawing, aswell as the destructor would do if i forget.
:
: So my question is when the server frees the used memory?
: Or have i a bad code?
: // i know ;-) it is not perfect in style
: Or have i free it my self by a client->server call?
:
: // CLASS SAMPEL //
: class nxImage
: {
: public:
: GR_IMAGE_ID image_id;
: int width, height;
:
:         void nxImage::LoadImage(char* path);
: void nxImage::DrawImage(GR_WINDOW_ID win_id, GR_GC_ID gc_id,
:                                 int start_x, int start_y);
: void nxImage::FreeImage(void);
: nxImage::nxImage(); // set image_id to 0
: nxImage::~nxImage(); // free image if not done bevor
:
: private:
: /* nothing for now */
: }; // CLASS nxImage
:
: void nxImage::LoadImage(char* path)
: {
: // holds the info, given by the sever, about the image
: GR_IMAGE_INFO image_info;
:
: // free current image if allready present
: if (image_id) {GrFreeImage(image_id);}
:
: if (!(image_id = GrLoadImageFromFile(path, 0))) // load new image
: {
:             fprintf(stderr, "Can't load %s image file\n", path);
:             exit(-1);
:         }//if()
:
: // get info of the current loaded image form server
: GrGetImageInfo(image_id, &image_info);
:
:         width  = image_info.width; // set height & width of the image
:         height = image_info.height;
:
: } // nxImage.LoadImage()
:
: void nxImage::DrawImage(GR_WINDOW_ID win_id, GR_GC_ID gc_id,
:                         int start_x, int start_y)
: {
: // Draws the image to the screen
: GrDrawImageToFit(win_id, gc_id,
:                          start_x, start_y,
:                          width, height, image_id);
:
: } //  nxImage.DrawImage()
:
: void nxImage::FreeImage(void)
: {
: // free current image if allready present
: if (image_id) {GrFreeImage(image_id);}
: image_id = 0;
:
: } // nxImage::FreeImage()
:
: nxImage::nxImage()
: {
:   image_id = 0; // set zero to show that no image is allready loaded
: } // nxImage::nxImage()
:
: nxImage::~nxImage()
: { // free current image if allready present
:   if (image_id) {GrFreeImage(image_id);}
: } // nxImage::~nxImage()
:
: // Code EXAMPLE //
:
: #define BACK "GIF/back5.gif" /* background    320x240 */
: #define DESO "GIF/deso.gif"  /* company logo  130x60  */
: #define ICON "GIF/icon.gif"  /* a icon  32x32         */
:
: nxImage image; // create a new image object
: image.LoadImage(BACK); // loading the first image -> memory alocated
: image.DrawImage(my_x.output_window, my_x.gc, 0, 0);
: image.LoadImage(DESO);
: image.DrawImage(my_x.output_window, my_x.gc,
:        (WHIDE/2)-(image.width/2), 100);
: image.LoadImage(ICON);
: image.DrawImage(my_x.output_window, my_x.gc, 40, 210)
: image.FreeImage();
: // freeing the last image -> memory shoud be completly delocated
: // but this isn't happening(tested on runtime with KDE Process Table)
:
: -- 
: Lust, ein paar Euro nebenbei zu verdienen? Ohne Kosten, ohne Risiko!
: Satte Provisionen für GMX Partner: http://www.gmx.net/de/go/partner
:
: ---------------------------------------------------------------------
: To unsubscribe, e-mail: ####@####.####
: For additional commands, e-mail: ####@####.####
:
:


Previous by date: 21 Oct 2005 06:23:32 +0100 Re: Multiline text, Greg Haerr
Next by date: 21 Oct 2005 06:23:32 +0100 Asian Fonts In Nano-X, Gil Glass
Previous in thread: 21 Oct 2005 06:23:32 +0100 Server don't free memory from images after releasing it with GrFreeImage, Michael Augst
Next in thread:


Powered by ezmlm-browse 0.20.