MCslp

News and commentary from the desk of MC Brown

  • About
  • About MCslp
  • Planet MCslp
  • MCslp Books
    • 0
      13 Oct 2008

      How to analyze memory leaks on Windows

      • Edit
      • Delete
      • Tags
      • Autopost
      We use valgrind to find memory leaks in MySQL on Linux. The tool is a convenient, and often enlightening way of finding out where the real and potential problems are location. On Windows, you dont have valgrind, but Microsoft do provide a free native debugging tool, called the user-mode dump heap (UMDH) tool. This performs a similar function to valgrind to determine memory leaks. Vladislav Vaintroub, who works on the Falcon team and is one of our resident Windows experts provides the following how-to for using UMDH:
      1. Download and install debugging tools for Windows from here MS Debugging Tools Install 64 bit version if you're on 64 bit Windows and 32 bit version otherwise.

      2. Change the PATH environment variable to include bin directory of Debugging tools. On my system, I added C:\Program Files\Debugging Tools for Windows 64-bit to the PATH.

      3. Instruct OS to collect allocation stack for mysqld with gflags -i mysqld.exe +ust. On Vista and later, this should be done in "elevated" command prompt, it requires admin privileges.

        Now collect the leak information. The mode of operation is that: take the heap snapshot once, and after some load take it once again. Compare snapshots and output leak info.

      4. Preparation : setup debug symbol path. In the command prompt window, do

        set _NT_SYMBOL_PATH= srv*C:\websymbols*http://msdl.microsoft.com/download/symbols;G:\bzr\mysql-6.0\sql\Debug

        Adjust second path component for your needs, it should include directory where mysqld.exe is.

      5. Start mysqld and run it for some minutes
      6. Take first heap snapshot

        umdh -p:6768 -f:dump1

        Where -p: actually, PID of my mysqld was 6768.
      7. Let mysqld run for another some minutes
      8. Take second heap snapshot

        umdh -p:6768 -f:dump2

      9. Compare snapshots

        umdh -v dump1 dump2 > dump.compare.txt

      10. Examine the result output file. It is human readable, but all numbers are in hex, to scare everyone except geeks.
      11. gflags -i mysqld.exe -ust

        Instruct OS not to collect mysqld user mode stacks for allocations anymore.

      These are 10 steps and it sounds like much work, but in reality it takes 15 minutes first time you do it and 5 minutes next time. Additional information is given in Microsoft KB article about UMDH KB 268343.
      • views
      • Tweet
    • 0
      9 Aug 2007

      Setting up the developer stack issues

      • Edit
      • Delete
      • Tags
      • Autopost
      There's a great post on Coding Horror about Configuring the Stack. Basically the gripe is with the complexity of installing the typical developer stack, in this case on Windows, using Visual Studio. My VS setup isn't vastly different to the one Jeff mentions, and I have similar issues with the other stacks I use. I've just set up the Ultra3 mobile workstation again for building MySQL and other stuff on, and it took about 30 packages (from Sun Freeware) just to get the basics like gcc, binutils, gdb, flex, bison and the rest set up. It took the best part of a day to get everything downloaded, installed, and configured. I haven't even started on modules for Perl yet. The Eclipse stack is no better. On Windows you'll need the JDK of your choice, plus Eclipse. Then you'll have to update Eclipse. Then add in the plugins and modules you want. Even though some of that is automated (and, annoyingly some of it is not although it could be), it generally takes me a few hours to get stuff installed. Admittedly on my Linux boxes it's easier - I use Gentoo and copy around a suitable make.conf with everything I need in it, so I need only run emerge, but that can still take a day or so to get everything compiled. Although I'm sure we can all think of easier ways to create the base systems - I use Parallels for example and copy VM folders to create new environments for development - even the updating can take a considerable amount of time. I suggest the new killer app is one that makes the whole process easier.
      • views
      • Tweet
    • 0
      11 Sep 2006

      Using static disks in Parallels for performance

      • Edit
      • Delete
      • Tags
      • Autopost
      Using a static disk, or even just multiple disks, within Parallels can make a big difference to performance. This is particularly true with Windows virtual machines within OS X; I've managed to change the boot time from about 30 seconds to under 20 just by changing to a static disk for VM. The default disk in Parallels is an expanding type - this saves disk space, because Parallels automatically adds to the size of the disk as you need it, but it also means that Parallels has to manage the allocated disk space, adding to the file used. Not only does the management imply a small overhead, there is a much larger chance of the file being fragmented. A more annoying effect is that the constant use of the expanding disk with virtual memory under Windows, means that size of the disk may increase just because you opened a large application once. You can get round this by creating a statically-sized disk, and then setting the virtual memory within your virtual host, to use this statically sized disk. To do this:
      1. Shutdown your virtual machine - you cannot do this with a machine in the paused stated, because you are effectively adding new hardware to the machine.
      2. Click Edit to edit the configuration for the virtual machine.
      3. Click Add, and select a new hard disk
      4. Unclick the Expanding checkbox and set the size; probably 1-2GB is fine, but keep in mind you will lose this amount of disk space permanently, even if your VM doesn't use it all.
      5. Save your configuration.
      6. Start up your VM and configure the new drive.
      For Windows:
      1. Log in as a user with Administrator privileges.
      2. Right click on My Computerand choose Manage.
      3. Choose Local Disk Management.
      4. Create a new partition/volume.
      5. Once the new disk is ready to use, right click on My Computer again, and choose Properties.
      6. Click the Advanced tab.
      7. Click Settings under Performance.
      8. Click the Advanced tab.
      9. Click Change under Virtual Memory.
      10. Reconfigure the VM settings, creating the new settings for the new drive (I recommend a lower value of 50MB and an upper value 2-10MB below the maximum size of the disk. Windows will use the minimum and dynamically increase it's usage up until the maximum.
      11. Remove the VM configuration for the original system/expanding disk.
      You should be all set. It's probably a good idea to run the Parallels Compressor and reduce the size of your disk now that you are no longer using the disk for virtual memory. For Linux, Solaris and other Unix variants you might want to run, the process is of course slightly different. For some environments, there are other benefits, but I'll cover that in a separate post.
      • views
      • Tweet
    • Search

    • Sites I Like

      • MC's LinkedIn
      • Sharon Penfold's LinkedIn
    • Tags

      • IBM DeveloperWorks
      • Articles
      • Open Source
      • Commentary
      • MySQL
      • Unix
      • Grids
      • Software
      • Hardware
      • General
      • Books
      • Solaris
      • Databases
      • System Administration
      • Interviews
      • ServerWatch
      • Reviews
      • Technology
      • Free Software Magazine
      • Mac OS X
      • Site News
      • LinuxWorld Magazine
      • Web Services
      • Scripting
      • Sun/Solaris
      • Programming
      • Rational
      • Eclipse
      • Linux
      • XML
      • Java
      • Web Development
      • LinuxToday
      • Step-by-step
      • Tips
      • Apple
      • Apple Developer Connection
      • FOSS
      • Computerworld
      • Development Environments
      • Microsoft
      • The Apple Blog
      • Virtualization
      • mysqlconf09
      • Book
      • C/C++
      • CouchOne
      • OS
      • Presentations
      • presentation
      • DTrace
      • OpenSolaris
      • couchdb
      • laptop
      • mysql08
      • mysqluc08
      • notebook
      • Backups
      • DocBook
      • Documentation
      • Example
      • Memcached
      • Web Servers
      • debugging
      • mysql08
      • mysqlconf09
      • mysqluc08
      • query analysis
      • query analysis
    • Archive

      • 2012 (4)
        • March (3)
        • February (1)
      • 2011 (1)
        • September (1)
      • 2008 (1)
        • October (1)
    • Obox Design
  • MCslp

    6439 Views
  • Get Updates

    Subscribe via RSS
    TwitterLinkedIn