I limited the lines of code causing a memory leak to the following useless piece of code obtained from the original windows application.
I already know the general issue with timers causing memory leak when the variables inside the callback (or tick event) are not properly disposed, that's why I put the two "using" sections in my function. Still I can not see what I am leaving unmanaged.
I thought about timer bombing but even if I set 1000 ms as interval the memory still increases until I get a memory exception.
Blockquote
class Program
{
    private static bool locked {get; set; }
    static void Main(string[] args)
    {
        System.Threading.Timer timer_log = new System.Threading.Timer(t_callback, null, 0, 100);
        Application.Run();
    }
    private static void t_callback(Object state)
    {
        if (locked == false)
        {
            locked = true;
            Leak.SetIcon();
            locked = false;
        }
    }
}
static class Leak
{
    private static NotifyIcon notifyIcon = new NotifyIcon();
    static public void SetIcon()
    {
        using (Bitmap bitmapIcona = new Bitmap(Properties.Resources.LoggerServiceImg))
        {
            using (Graphics graphicsIcona = Graphics.FromImage(bitmapIcona))
            {
                notifyIcon.Icon = Icon.FromHandle(bitmapIcona.GetHicon());
            }
        }
    }
}
Blockquote
