Project

General

Profile

Actions

Emulator Issues #1196

closed

Huge memory leak when compressing Wii games.

Added by Xtreme2damax over 15 years ago.

Status:
Fixed
Priority:
Normal
Assignee:
Category:
Logic
% Done:

0%

Operating system:
Windows
Issue type:
Feature request
Milestone:
Regression:
No
Relates to usability:
No
Relates to performance:
No
Easy:
No
Relates to maintainability:
Yes
Regression start:
Fixed in:

Description

What steps will reproduce the problem?

  1. Right Click Wii game to compress
  2. Compression starts
  3. Let compression run.

What is the expected output? What do you see instead?

I expected it not to eat up so much memory, when compressing a Wii game
there's a huge memory leak that eats up 99% - 100% of my ram, my system
runs sluggishly even after compression is finished until I reboot.

What version of the product are you using? On what operating system?

I've tried the 32-bit, 64-bit, and IL builds of revision 3877, all exhibit
the same problem when compressing Wii games.

I'm using Windows Vista x64 SP2.

Please provide any additional information below.

My system specifications are: Core2Duo E8500, 4 GB of DDR2 Dual Channel
Ram, Nvidia Geforce 9800 GT.


Related issues 1 (0 open1 closed)

Blocks Emulator - Emulator Issues #2043: Release bug trackerFixednakeee

Actions
Actions #1

Updated by lpfaint99 over 15 years ago

hmm I havent seen any memory leaks here, just compressed about 20 wii games with no
slowdown

Actions #2

Updated by Xtreme2damax over 15 years ago

It does this to me, while the game is compressing memory usage rises up to 99% - 100%
until the process finishes, then my system is sluggish until a reboot. I can't
reproduce the same exact behavior every time, sometimes it eats up less and sometimes
more.

Compressing Gamecube games doesn't seem to have this effect, only when compressing
Wii games and can be reproduced most of the time.

Perhaps it's a 64-bit Vista issue when compressing Wii games, I thought I would just
make a mention of it in case there is anything wrong. If anyone else is having the
same problem, I have seen it reported on the issue tracker.

Actions #3

Updated by Anonymous over 15 years ago

um, this IS the issue tracker?

yes i know of this issue, dunno what causes it (haven't really looked). Should probably
do that sometime...

Actions #4

Updated by Xtreme2damax over 15 years ago

I meant that if someone else was having the same problem, I didn't see it reported
here, since I performed a search before filing the report.

Actions #5

Updated by lpfaint99 over 15 years ago

i'm on vista64 as well, strange that I didnt see the leak

Actions #6

Updated by sskkiipp over 15 years ago

Hi there,

just tried on win 7 x64, works perfect. ram usage ~32/33MB while compressing.

Does it happen with all your wii games?

Actions #7

Updated by marcus over 15 years ago

  • Status changed from New to Questionable
Actions #8

Updated by Xtreme2damax over 15 years ago

For the most part this happens every time I try to compress a Wii game, one time
memory shot up to 99% - 100% usage on Vista x64 when compressing a Wii game then
dropped after the compression was finished. My system continued to run sluggishly
afterward until I rebooted my machine.

Actions #9

Updated by Anonymous over 15 years ago

  • Status changed from Questionable to Accepted
Actions #10

Updated by Anonymous over 15 years ago

so i've made the issue reproducible: the memleak happens when the scrubber is run, then
while the compressor loops, memory usage goes crazy. At the moment I have no idea why.

Actions #11

Updated by Anonymous about 15 years ago

  • Status changed from Accepted to Work started

could someone try r4588?
In my testing, memleaks are greatly reduced, or even fixed

Actions #12

Updated by Anonymous about 15 years ago

bleh, it fixes the memleak when scrubbing, but not when compressing...

Actions #13

Updated by baby.lueshi almost 15 years ago

It turns out it isn't a memory leak using up all the memory; it's the output buffer.

I guess when we get to data that doesn't compress very well, we start adding stuff to
the output buffer faster than it can write it to the disk. We keep filling it, and
eventually the computer runs out of memory.

This patch should fix it. You can adjust the value to make it flush the buffer more
or less frequently. Right now it flushes the buffer about every 16,000 blocks.

Actions #14

Updated by baby.lueshi almost 15 years ago

Also, I still get a big memory leak when scrubbing Wii games. If I scrub the game
then stop Dolphin, I can compress the game fine with no leaking.

Actions #15

Updated by Anonymous almost 15 years ago

Ehhh, this issue is about the memleak when scrubbing + compressing wii games. I haven't
noticed any large use of memory in other scenarios.
(ie - what does your patch fix?)

Actions #16

Updated by baby.lueshi almost 15 years ago

When compressing large Wii games, if your hard drive isn't fast enough (usually when
it's getting close to full) the output buffer grows faster than it can write to the
hard disk, causing extreme memory usage. (I think it does so for GameCube games too,
but because they're usually much smaller, nobody really notices because they never
use up that much RAM.) This patch periodically flushes the output buffer to free up
memory during the compression process.

The wierd thing is, it seems the scrubber keeps leaking memory even when the
scrubbing process ends and the actual compression begins. The scrubber memory
problems might also be file buffer related.

Actions #17

Updated by Anonymous almost 15 years ago

Yes I understood what you patch does, I was just saying that I had never noticed
extreme memory usage due to that :) (Which probably just means I wasn't looking hard
enough).

"The scrubber memory problems might also be file buffer related."
Certainly possible. Here is were all the fileIO in DiscScrubber is performed:
http://tinyurl.com/ydww2r6
Feel free to play around with that loop (I realize it's pretty tight...)
Probably the solution is to create a map of all the contiguous "free" area, and do
just a few writes (for each free section), instead of such an extremely large amount.

Actions #18

Updated by baby.lueshi almost 15 years ago

You probably never noticed it because your hard drive was fast. Mine is kind if slow
(and kind of full) so I got this problem compressing any Wii game. (Except NSMB Wii,
which compresses to only about 300mb.)

I'll look at the scrubber code to see if I can find the problem with it.

Actions #19

Updated by baby.lueshi almost 15 years ago

Turns out the issue with the scrubber is some weird conflict between Windows' native
CreateFile and C's file functions. PlainFileReader (which the scrubber uses) uses
CreateFile and pretty much everything else uses the C way. I changed PlainFileReader
to use C's standard file functions. This could have side effects, but I haven't
noticed any.

(this patch was originally a part of the one I made for Issue 2214, so tell me if you
can't apply it.)

Actions #20

Updated by XTra.KrazzY almost 15 years ago

oh yes! baby.lueshi this patch is so much better. Who needs those ifdefs anyway?

Actions #21

Updated by bztdlinux almost 15 years ago

  • Issue type set to Feature request
  • Category set to logic
  • Priority set to Normal
  • Relates to maintainability set to Yes
  • Operating system Windows added

XK, is that sarcasm, or what exactly? This patch looks great, I will probably
commit it with minor to no changes.

Actions #22

Updated by XTra.KrazzY almost 15 years ago

Nope, no sarcasm there. Just one too many exclamation marks and stupid questions.

Cross-platform file management is the way to go. I don't really know who even wrote
that windows only code in the first place and why...

Actions #23

Updated by baby.lueshi almost 15 years ago

The only problem it might have is opening large files, because from what I've read,
Windows sometimes has problems handling files over 2GB when not using its native file
functions. However, I didn't run into any problems testing both the 32 and 64 bit
versions.

Actions #24

Updated by XTra.KrazzY almost 15 years ago

From what I heard, there's functions such as fseek64 and more of the sort. It's even
used in the Common::File class IIRC.

Actions #25

Updated by baby.lueshi almost 15 years ago

I didn't notice this before, but Dolphin already overrides the 32-bit versions of
fseek/ftell with the respective 64-bit versions (in CommonFuncs.h)

So this patch SHOULD be fine to apply.

Actions #26

Updated by Anonymous almost 15 years ago

  • Status changed from Work started to Fixed

committed (but without the fflush() call).
don't really see why fflush is needed - the OS should block if the buffer is full, no?
I also noticed slower speed when fflush()ing so much - but if you still say it's
needed, I guess we'll put it in. (I don't notice any positive effects - I guess my HDDs
are too fast :P )

Actions #27

Updated by baby.lueshi almost 15 years ago

The fflush was really just left over from my previous attempt to fix this, so it
shouldn't be necessary.

Actions

Also available in: Atom PDF