About software, technology and random things


Memory Leaks / Problems with Long-Running Symfony / Doctrine Console Applications


I recently built several console applications that have to keep running as daemons as part of a more complex website. As soon as I added Doctrine for its highly comfortable ORM functionality, I noticed a significant increase in the applications' memory usage, which made sense because it would load Doctrine's code in order to use it. The worst part of it, however, was that the processes kept eating up more and more memory the longer they ran and with each Doctrine query they executed. Finally the processes ended up being killed by Linux's OOM Killer due to the high amount of memory that they wanted allocated for them.

Clearing the Doctrine Entity Manager ($entityManager->clear()) and triggering PHP's garbage collection manually did not help at all. So I assumed it had something to do with the data that Doctrine accumulates in the background.

During my research I finally stumbled upon this Stack Overflow question: Memory leaks Symfony2 Doctrine2 / exceed memory limit

Apparently, Doctrine uses an SQL Logger to log each and every query it uses when running in debug mode.

Due to the nature of Symfony console applications starting up in the dev environment by default when launching them from the command line, it also kept enabling the debug mode. That in turn enabled the SQL Logger which gathered more and more data and kept it in memory.

I decided to launch the processes by simply manually disabling the debug flag. Using the dev environment is not a problem for me, so I just did the following:

$ php app/console custom:command --no-debug

You could also set the environment variable SYMFONY_DEBUG to 0 before launching the command without the --no-debug flag, as it also respects its value - refer to app/console's source code.

Alternatively, you could start it in a non-dev environment:

$ php app/console custom:command --env=prod


$ php app/console custom:command -e prod

or just set the environment variable SYMFONY_ENV before launching it.

This way, the SQL Logger is not enabled.

My processes have been running at stable memory usage size ever since.

Another way would be to deactivate the SQL Logger in the code by principle, but that would be defeating the purpose of the nice built-in features of enabling/disabling the debugging mode, so I rather chose the first path. It might come in handy sooner or later after all, and reverting those changes just to re-enable the SQL Logger would be an unnecessary pain.

I hope this was helpful to you. It certainly took me some time to get behind it.


Using msysgit With PuTTY Pageant & Plink


If you have installed msysgit and are planning on using it in combination with Pageant from the PuTTY tool suite, you might run into the problem that it does not attempt to use any of the keys you have already loaded into Pageant. You can fix this by telling msysgit which program to use for the git fetch and pull operations:

  • Open your System window (Windows + Pause or "Start" => Right-click on "Computer" => "Properties")
  • Click on "Advanced system settings" (on the left)
  • Click on "Environment Variables..." (on the bottom)
  • Add a new system variable (or user variable if you just want this setting for the current user): "New..."
  • Variable name: GIT_SSH
    Variable value: (path to plink.exe) for example: C:\Program Files (x86)\PuTTY\plink.exe (important: just the path, no quotation marks at the beginning or the end!)
  • If you haven't already on this system / user, connect to the server via PuTTY in order to get the SSH server fingerprint prompt and remember it
  • Close any existing Git Bash / msysgit instances and start it up again

This should do it!

I hope this was helpful.

Thanks for reading!



Mozilla Thunderbird: Changing the EHLO / HELO Value in the “Received”-Header for Outgoing Mail


If you have had a look at your outgoing e-mail headers that you've sent from Mozilla Thunderbird, you might have noticed that Thunderbird uses the IP of the network interface that it uses to connect to the internet with by default. If you are using a router on your network, this is a private IP from your LAN (for example instead of one that might be of actual use.


Received: from ([] helo=[]) by (incoming-mta-service) with esmtpsa (outgoing-mta-service) id
 0a1b2c-3D4e5F6G7h-0a1B2c for <>; Sun, 02 Nov 2014 20:55:41 +0100

where "" is the publicly facing IP and "" is its hostname.

If you do not wish to expose this information to every and all recipients of the e-mails you are sending with Thunderbird to (maybe out of security concerns in a business environment), you can set the EHLO / HELO value manually for every outgoing e-mail sent by the Thunderbird client with your current user profile and even for every simple SMTP server individually.

Here's how:


  • Open your Thunderbird options ("Tools" => "Options")
  • "Advanced" => "Config Editor..."
  • Create (or edit) the entry named "mail.smtpserver.default.hello_argument". If you need to create it, use right-click => "New" => "String".
  • Change the value to the desired IP or hostname (FQDN).

Per SMTP server

  • Open your Thunderbird options ("Tools" => "Options")
  • "Advanced" => "Config Editor..."
  • Create (or edit) the entry named "mail.smtpserver.smtp<number>.hello_argument" where <number> is the ID for the SMTP server you would like to apply the setting to. Type "mail.smtpserver.smtp" to see which ones are available and which ID they have. If you need to create the entry, use right-click => "New" => "String".
  • Change the value to the desired IP or hostname (FQDN).

Technically this value is not relevant for sending/receiving the mail, but because it might be used for spam scoring or simply out of courtesy I would recommend entering a valid IP / hostname.

I myself am using

Thanks for reading!



Deleting Huge Directories in Windows Via Command Prompt


If you'd like to delete a huge folder / directory in Windows with maybe thousands or hundreds of thousands of files inside, doing that via Explorer might cost you a lot more time than via command prompt.

Here's how to do it faster:

  1. Open the command prompt by using "Start" => "cmd" and navigating to the desired path via "cd <path>" or "pushd <path>"
    - OR -
    navigate to the folder in the Explorer and use Shift + right-click and "Open command window here"
    (Note: if deleting the desired folder requires elevated privileges, you will have to start a command prompt in elevated mode and navigate the old-fashioned way)
  2. Use the following command:
    rmdir /s /q folder

A little explanation about rmdir's flags:

  • /s: removes the directory itself including all the contained files and subdirectories
  • /q: forces deletion and does not ask for approval

Doing this can be very helpful in a coding environment where you can easily end up with thousands of small files.

Thanks for reading!



Viewing Hidden Devices in Windows Device Manager


If you are trying to find a device that has been hidden in your Windows Device Manager, for example because you don't have it plugged in at the moment, you might find this little guide handy.

  1. Open the command prompt ("Start" => "cmd")
  2. Enter
    set devmgr_show_nonpresent_devices=1
  3. Then start the Device Manager from the command prompt via
  4. In the Device Manager, click "View" => "Show hidden devices"

I hope this helped ūüôā

Thanks for reading!



Installing the Logitech F710 Wireless Gamepad on Windows 7 x64 (XInput Driver)

Update from 2015-10-18: Windows 10 Pro (x64) does not appear to require this workaround. It automatically installed the correct driver and allowed me to use the controller right away.


In order to be able to benefit from using the XInput mode for the Logitech F710 Wireless Gamepad, of course you need to install the correct driver. This is made a little hard for Windows 7 x64 seeing as there is no driver that comes with the device itself.

I found a guide on how you can manage it by using Microsoft's official Xbox 360 Controller driver.

Be careful though, you're messing with driver files. Use this guide at your own risk.

  1. Go to the Microsoft Hardware downloads page:
  2. Click on the category "Gaming"
  3. Click on the link "Xbox 360 Wireless Controller for Windows"
  4. Download the correct version of the file (Windows 7 64-bit only) and install it
  5. Open the Device Manager (e.g. [Windows]+[Break] => Device Manager)
  6. Right-click on the entry with "Logitech F710" in its name and the yellow triangle icon in front of it
  7. Open its properties
  8. Switch to the "Details" tab
  9. Choose the property "Hardware Ids"
  10. Right-click on the one without the "&REV_<Number>" at the end of the name and copy it. It should look something like this: USB\VID_046D&PID_C21F
  11. Go to the directory in which you installed the Xbox 360 Accessories Software a minute ago: C:\Program Files\Microsoft Xbox 360 Accessories
  12. Open the file Xusb21.inf with a plain text editor like Notepad
  13. At the top in the commented section you can see the line containing "Wireless Common Controller USB\Vid_045E&Pid_0719". Search for "USB\Vid_045E&Pid_0719" and replace each occurence with the hardware ID you copied earlier. Afterwards, save it to the file. You might need to have your editor program in elevated privilege mode in order to do so.
  14. Go back to the Device Manager with the open F710 properties window
  15. Switch to the "Driver" tab
  16. Click on the "Update Driver..." button
  17. In the assistant, choose "Browse my computer for driver software"
  18. Choose the path "C:\Program Files\Microsoft Xbox 360 Accessories"
  19. Confirm the driver warning and you're good to go

To check if it really worked, you can just press the Logitech button on the game controller and it should cause a little frame with the Xbox logo, the text "Click for Help" and a down-pointing arrow button and an X button to pop up in the lower center of your screen.

I do not usually recommend modifying driver files like that, but I have used this method before and it worked for me, so I stopped looking for a better way, as there doesn't seem to be any official solution provided by Logitech themselves (which is a shame).

Original post and the ones who can be credited with this solution: post by breakfastmonkey on the official Logitech forums (referencing a couple of previous posts in the same thread).

Thanks for reading.


Access Control via Hybrid .htaccess for Both Apache HTTPd 2.2 and 2.4


If you're running the Apache HTTPd in the versions 2.2 and 2.4 in different environments but would like to control access to certain directories (include, lib, ...) via Apache, chances are that you don't want to use one 2.2 specific file and a different one for 2.4, especially if you keep transferring and synchronizing the files between those different setups.

Between versions 2.2 and 2.4 a couple of things have changed. The perhaps most prominent change would be the one that comes with the new mod_authz_host module and deals with authorization / access control. Instead of using Order, Allow, Deny and/or Satisfy you are now advised to use the new Require directive.

So what do you do if you cannot switch every .htaccess over to the new format for reasons like the one mentioned in the beginning?

You could in fact enable the mod_access_compat module and keep rolling with the old configuration. But that would only mean procrastinating until you would finally have to deal with it anyway.

The better solution is to use configurations that are not even necessarily dependent on your Apache version (remember, you could just load the legacy compatibility module in 2.4), but in fact check for the correct module to work with. The key element to work with here is the IfModule directive.

# Apache 2.4
<IfModule mod_authz_core.c>
    Require all denied

# Apache 2.2
<IfModule !mod_authz_core.c>
    Order Allow,Deny
    Deny from all

As you can see, there are two checks that basically work as an "if ... else" selection. The rest should be self-explanatory.

For more information about the new way of handling access with the Apache HTTPd 2.4, please refer to the official documentation.

I hope this was of any help to you.

Thanks for reading.


Making Traceroutes Work with a Firewall (Windows)


Even though I've had software firewalls in action for years now, I haven't really come across too many instances where I'd need traceroutes. The few times I did, however, I noticed that I only got output like the following:


Tracing route to []
over a maximum of 30 hops:

  1     *        *        *     Request timed out.
  2     *        *        *     Request timed out.
  3     *        *        *     Request timed out.
  4     *        *        *     Request timed out.
  5     *        *        *     Request timed out.
  6     *        *        *     Request timed out.
  7     *        *        *     Request timed out.
  8     *        *        *     Request timed out.
  9     *        *        *     Request timed out.
 10     *        *        *     Request timed out.
 11    50 ms    50 ms    50 ms []

Trace complete.

The number of hops would of course vary for the specific host / IP address.

Today I had to use traceroute in order to analyze a couple of networking problems. That was the incentive I needed to look up why it didn't work.

The fact that not even my router was showing up was a big indicator that something was wrong with my local firewall settings.

After searching the web for a couple of minutes, I found out what I was looking for at this page:

Traceroute is using ICMP packets (plus UDP on Linux systems, but that's outside the scope of this blog entry. You can read more about it on the page I linked above). But even for an outgoing traceroute you need to accept incoming ICMP packets.

Which ones? These:

  • ICMP TTL Expired (Type 11, Code 0)
  • ICMP Port Unreachable (Type 3, Code 3)

Once you've enabled these types of packets for incoming traffic in your firewall(s), you'll see that your traceroute will now function as it should.

If your firewall does not allow you to configure accepting specific types of ICMP packets, try allowing incoming ICMP packets altogether (if that's not too much of a compromise for you).

Anyway, long-ish story short: It's working now ūüôā

Thanks to the webmaster of the page I linked above! And thanks to you for reading.


Hiding the Closing Button (X) on the Firefox Add-on Bar


Since the introduction of Firefox 3 or 4 (I don't quite remember) and the removal of the status bar I have liked to use the Add-on bar instead. In the newer versions of Firefox, however, that Add-on bar comes with a closing button, an X on the very left.

Unfortunately, there is no built-in option to disable that particular button. Right-clicking and "Customize ..." doesn't allow moving or removing that button either.

After searching the web for a while, I stumbled upon a Google Groups thread:

In that thread, Chris Ilias gave a simple solution (thank you!):

  1. Go to your Firefox profile directory. For that, just enter about:support in your URL bar (or click on Firefox => Help => Troubleshooting) and click on the "Open Containing Folder" button next to "Profile Directory".
  2. Close Firefox. (So maybe it would be better to continue reading these instructions beforehand and/or copy them into a text editor. ūüôā )
  3. Enter the subfolder "chrome" in the profile directory.
  4. Open the file "userChrome.css". If it does not exist, copy "userChrome-example.css" and rename the copy to "userChrome.css".
    If you are using Notepad, you won't be able to see line breaks / new lines. Therefore I recommend using a program that can interpret these kinds of line breaks, for example TextPad, Notepad++ or even WordPad, which comes with Windows itself.
  5. Add the following line to the file:
    #addonbar-closebutton { display: none }
  6. That's it! Save the file, start up Firefox again and enjoy the Add-on bar without a closing button!

These instructions were written for Firefox 11, but they should stay viable for the next couple of versions as well.

I hope this was of any help to you.

Thanks for reading!


Restoring Syntax Highlighting to Vim


After doing a couple of updates on my servers today, I noticed that one of them had syntax highlighting in vim disabled. I double-checked to see that it was still vim that was installed, and not vi. Indeed it was, so I tried entering a couple of vim commands in order to re-enable syntax highlighting.

A couple of minutes of trying and searching the Internet went by till I got the idea to directly compare the vim version info both on one of my servers that had it working properly and the one that didn't. It turned out that even though it was the same version number and build with the same compile time it had a certain difference: one line said "Tiny version without GUI." vs. "Huge version without GUI.". The tiny version was the one that wasn't highlighting correctly.

So I checked out what the package manager thought of this:

# yum list *vim*
Installed Packages
vim-common.i386                                   2:7.0.109-7.el5                                  installed
vim-enhanced.i386                                 2:7.0.109-7.el5                                  installed
vim-minimal.i386                                  2:7.0.109-7.el5                                  installed
Available Packages
vim-X11.i386                                      2:7.0.109-7.el5                                  base

Somehow during updating it had apparently decided to install the vim-minimal package as well. And of course it wasn't installed on the server on which vim worked as it should.

Fair enough. I thought to myself that removing should fix it, but when I tried to it said the following:

# yum remove vim-minimal
Loaded plugins: fastestmirror
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package vim-minimal.i386 2:7.0.109-7.el5 set to be erased
--> Processing Dependency: vim-minimal for package: sudo
--> Running transaction check
---> Package sudo.i386 0:1.7.2p1-13.el5 set to be erased
--> Finished Dependency Resolution

Dependencies Resolved

 Package                   Arch               Version                         Repository               Size
 vim-minimal               i386               2:7.0.109-7.el5                 installed               581 k
Removing for dependencies:
 sudo                      i386               1.7.2p1-13.el5                  installed               861 k

Transaction Summary
Remove        2 Package(s)
Reinstall     0 Package(s)
Downgrade     0 Package(s)

Is this ok [y/N]:

That was weird. It felt the need to remove sudo along with it. Of course that was not okay for me, so I tried looking for a parameter for vim in order to ignore the dependencies, but apparently there are none (any more).

The solution I found after a couple of more minutes of searching the Internet was to remove the package via the actual rpm program. But don't you need the original rpm file for vim-minimal? No, you don't!

First you have to find out the complete package name, however. That can be done like this:

# rpm -qa | grep vim-minimal

And finally just use the following command:

# rpm -e --nodeps vim-minimal-7.0.109-7.el5.i386

whereas the last parameter is of course the proper name of the package in question. --nodeps, as you might have figured already, stands for "no dependencies" and removes the package without any questions asked.

In the end, these simple steps restored the syntax highlighting functionality for my vim.

Let's hope that after the next update it doesn't decide to go monochrome again.

Thanks for reading!