Re: Fwd: Memory leak in WineMine

2000-04-02 Thread gerard patel

At 05:49 PM 3/31/00 -0500, you wrote:

snip this leakage problem again

Could you try this patch against graphics/x11drv/init.c ? 
It seems to fix the leakage for me.

--- init.c.orig Sun Apr  2 16:56:14 2000
+++ init.c  Sun Apr  2 19:27:05 2000
@@ -241,7 +241,8 @@
 {
 BITMAPOBJ *bmp = (BITMAPOBJ *) GDI_GetObjPtr( dc-w.hBitmap,
   BITMAP_MAGIC );
-   X11DRV_CreateBitmap( dc-w.hBitmap );
+if (!bmp-physBitmap)
+X11DRV_CreateBitmap( dc-w.hBitmap );
 physDev-drawable  = (Pixmap)bmp-physBitmap;
 physDev-gc= TSXCreateGC(display, physDev-drawable, 0, NULL);
 dc-w.bitsPerPixel = bmp-bitmap.bmBitsPixel; 

Gerard




Fwd: Re: Fwd: Memory leak in WineMine

2000-04-01 Thread Dave Pickles

On Fri, 31 Mar 2000, Ove Kaaven wrote:
On Fri, 31 Mar 2000, Joshua Thielen wrote:

 After checking out the memory leak, I think I've narrowed it down to this code
 snippet:
 
 ---in main.c---
  hMemDC = CreateCompatibleDC( hdc );
  SelectObject (hMemDC, p_board-hMinesBMP);
 
  BitBlt( hdc,
  (col - 1) * MINE_WIDTH + p_board-mines_rect.left,
  (row - 1) * MINE_HEIGHT + p_board-mines_rect.top,
  MINE_WIDTH, MINE_HEIGHT,
  hMemDC, 0, offset * MINE_HEIGHT, SRCCOPY);
 
  DeleteDC( hMemDC );
 --
 
 Am I doing anything incorrect here?

Yes, but it may be unrelated to the memory leak:
The first SelectObject() has a return value: it returns the previously
selected bitmap. You are supposed to select the original bitmap back into
the memory DC before calling DeleteDC on it. But I don't know if it
actually makes a difference in practice.

It can make a difference. I'm not sure about this particular example but
one of my programs had a leak where I wasn't deselecting a custom pen
before destroying the DC, and the GDI heap filled up with pens.

However IMHO the WineMine problem is actually within Wine itself. Compiling
and running WineMine under Win95 there is no leak. Running the same
executable under Wine (or building a Winelib version) we get the leak.
Perhaps Joshua you shouldn't try too hard to work around the problem.

Despite all the time testing I'm still no better at playing the game ;-)

Dave Pickles
---




Re: Fwd: Memory leak in WineMine

2000-03-31 Thread Ove Kaaven


On Fri, 31 Mar 2000, Joshua Thielen wrote:

 After checking out the memory leak, I think I've narrowed it down to this code
 snippet:
 
 ---in main.c---
  hMemDC = CreateCompatibleDC( hdc );
  SelectObject (hMemDC, p_board-hMinesBMP);
 
  BitBlt( hdc,
  (col - 1) * MINE_WIDTH + p_board-mines_rect.left,
  (row - 1) * MINE_HEIGHT + p_board-mines_rect.top,
  MINE_WIDTH, MINE_HEIGHT,
  hMemDC, 0, offset * MINE_HEIGHT, SRCCOPY);
 
  DeleteDC( hMemDC );
 --
 
 Am I doing anything incorrect here?

Yes, but it may be unrelated to the memory leak:
The first SelectObject() has a return value: it returns the previously
selected bitmap. You are supposed to select the original bitmap back into
the memory DC before calling DeleteDC on it. But I don't know if it
actually makes a difference in practice.




Re: Fwd: Memory leak in WineMine

2000-03-31 Thread Joshua Thielen

 Yes, but it may be unrelated to the memory leak:
 The first SelectObject() has a return value: it returns the previously
 selected bitmap. You are supposed to select the original bitmap back into
 the memory DC before calling DeleteDC on it. But I don't know if it
 actually makes a difference in practice.

The Borland docs do this. However, Petzold doesn't do this. It doesn't affect the
memory leak, though. I guess I'll be on the safe side and put it in the next patch
(which will be sent if I ever can fix this memory leak).
Thanks,

Joshua

_
NetZero - Defenders of the Free World
Click here for FREE Internet Access and Email
http://www.netzero.net/download/index.html




Re: Fwd: Memory leak in WineMine

2000-03-31 Thread Peter Hunnisett

Well if the leak appears to be comming from the CreateCompatilbeDC,
my changes will have reduced the impact since we were doing some
pretty massive creation/deletion for DrawMine. I didn't even look
for a leak, though.

The code does have that pattern in several places. Which is causing it,
or are they all.

What about the fact that SelectObject can return the old handle? Could that
be your leak - handle to a resource?

In message "Re: Fwd: Memory leak in WineMine", 
"Joshua Thielen" [EMAIL PROTECTED] writes:

After checking out the memory leak, I think I've narrowed it down to this code
snippet:

---in main.c---
 hMemDC = CreateCompatibleDC( hdc );
 SelectObject (hMemDC, p_board-hMinesBMP);

 BitBlt( hdc,
 (col - 1) * MINE_WIDTH + p_board-mines_rect.left,
 (row - 1) * MINE_HEIGHT + p_board-mines_rect.top,
 MINE_WIDTH, MINE_HEIGHT,
 hMemDC, 0, offset * MINE_HEIGHT, SRCCOPY);

 DeleteDC( hMemDC );
--

Am I doing anything incorrect here?

After commenting out various parts, I believe the leak occurs in
CreateCompatibleDC or DeleteDC, but I could not find any bugs in these
functions. Actually, I did notice that origDC never gets unlocked in
CreateCompatibleDC, is this a bug? Unlocking this does not stop the memory
leak in winemine, however.

Joshua Thielen

_
NetZero - Defenders of the Free World
Click here for FREE Internet Access and Email
http://www.netzero.net/download/index.html



Ciao,
Peter Hunnisett
[EMAIL PROTECTED]





Re: Fwd: Memory leak in WineMine

2000-03-31 Thread H.Takeshima


for example, this code may be valid only in windows 9x,
invalid in windows 3.1:
  hDC = Create[Compatible]DC();
  SelectObject( hDC, (anyobject) );
  bitblt etc.
  DeleteDC( hDC );

in windows 3.1,
 original handle of selected object should be restored:
  hDC = Create[Compatible]DC();
  hObj = SelectObject( hDC, (anyobject) ); - save handle
  bitblt etc.
  SelectObject( hDC, hObj ); - restore handle
  DeleteDC( hDC );


Hidenori Takeshima





Fwd: Memory leak in WineMine

2000-03-26 Thread Dave Pickles


Playing WineMine in 'expert' mode for 15 minutes (I'm no expert ;-)) the
machine becomes very sluggish. 'top' reports that the winemine process has
grown from 4Mb to 36Mb, and the X process from 22Mb to 64Mb.

This is on today's CVS, btw.

Dave Pickles