TV Server memory leak in 1.2.0b (1 Viewer)

gibman

Retired Team Member
  • Premium Supporter
  • October 4, 2006
    2,998
    1,372
    Usa
    Home Country
    Ethiopia Ethiopia
    I took the static code analyzer for a quick spin (vs2010)

    I created a custom ruleset containing warnings about "IDisposable" (and nothing else) for tvservice and tvlib projects.

    results =>

    tvservice:
    Code:
    	Warning	398	CA1001 : Microsoft.Design : Implement IDisposable on 'DiskManagement' because it creates members of the following IDisposable types: 'Timer'. If 'DiskManagement' has previously shipped, adding new members that implement IDisposable to this type is considered a breaking change to existing consumers.	C:\Development\TvEngine.clean\TVLibrary\TvService\DiskManagement\DiskManagement.cs	32	TvService
    	Warning	399	CA1063 : Microsoft.Design : Provide an overridable implementation of Dispose(bool) on 'EpgCard' or mark the type as sealed. A call to Dispose(false) should only clean up native resources. A call to Dispose(true) should clean up both managed and native resources.	C:\Development\TvEngine.clean\TVLibrary\TvService\Epg\EpgCard.cs	36	TvService
    	Warning	400	CA1063 : Microsoft.Design : Modify 'EpgCard.Dispose()' so that it calls Dispose(true), then calls GC.SuppressFinalize on the current object instance ('this' or 'Me' in Visual Basic), and then returns.	C:\Development\TvEngine.clean\TVLibrary\TvService\Epg\EpgCard.cs	763	TvService
    	Warning	402	CA1063 : Microsoft.Design : Provide an overridable implementation of Dispose(bool) on 'EpgGrabber' or mark the type as sealed. A call to Dispose(false) should only clean up native resources. A call to Dispose(true) should clean up both managed and native resources.	C:\Development\TvEngine.clean\TVLibrary\TvService\Epg\EpgGrabber.cs	51	TvService
    	Warning	403	CA1063 : Microsoft.Design : Modify 'EpgGrabber.Dispose()' so that it calls Dispose(true), then calls GC.SuppressFinalize on the current object instance ('this' or 'Me' in Visual Basic), and then returns.	C:\Development\TvEngine.clean\TVLibrary\TvService\Epg\EpgGrabber.cs	187	TvService
    	Warning	404	CA1001 : Microsoft.Design : Implement IDisposable on 'Recorder' because it creates members of the following IDisposable types: 'ManualResetEvent'. If 'Recorder' has previously shipped, adding new members that implement IDisposable to this type is considered a breaking change to existing consumers.	C:\Development\TvEngine.clean\TVLibrary\TvService\CardManagement\CardHandler\Recorder.cs	34	TvService
    	Warning	405	CA1001 : Microsoft.Design : Implement IDisposable on 'RecordingManagement' because it creates members of the following IDisposable types: 'Timer'. If 'RecordingManagement' has previously shipped, adding new members that implement IDisposable to this type is considered a breaking change to existing consumers.	C:\Development\TvEngine.clean\TVLibrary\TvService\DiskManagement\RecordingManagement.cs	27	TvService
    	Warning	410	CA2000 : Microsoft.Reliability : In method 'Service1.Main(string[])', object 's' is not disposed along all exception paths. Call System.IDisposable.Dispose on object 's' before all references to it are out of scope.	C:\Development\TvEngine.clean\TVLibrary\TvService\Service1.cs	133	TvService
    	Warning	411	CA2000 : Microsoft.Reliability : In method 'Service1.Main(string[])', call System.IDisposable.Dispose on object 'ti' before all references to it are out of scope.	C:\Development\TvEngine.clean\TVLibrary\TvService\Service1.cs	105	TvService
    	Warning	412	CA2000 : Microsoft.Reliability : In method 'Service1.Main(string[])', call System.IDisposable.Dispose on object 'ti' before all references to it are out of scope.	C:\Development\TvEngine.clean\TVLibrary\TvService\Service1.cs	118	TvService
    	Warning	413	CA1001 : Microsoft.Design : Implement IDisposable on 'TimeShifter' because it creates members of the following IDisposable types: 'ManualResetEvent'. If 'TimeShifter' has previously shipped, adding new members that implement IDisposable to this type is considered a breaking change to existing consumers.	C:\Development\TvEngine.clean\TVLibrary\TvService\CardManagement\CardHandler\TimeShifter.cs	33	TvService
    	Warning	414	CA2000 : Microsoft.Reliability : In method 'TsCopier.DoCopy()', call System.IDisposable.Dispose on object 'reader' before all references to it are out of scope.	C:\Development\TvEngine.clean\TVLibrary\TvService\TsCopier.cs	75	TvService
    	Warning	415	CA2000 : Microsoft.Reliability : In method 'TsCopier.DoCopy()', call System.IDisposable.Dispose on object 'writer' before all references to it are out of scope.	C:\Development\TvEngine.clean\TVLibrary\TvService\TsCopier.cs	76	TvService
    	Warning	416	CA2202 : Microsoft.Usage : Object 'reader' can be disposed more than once in method 'TsCopier.DoCopy()'. To avoid generating a System.ObjectDisposedException you should not call Dispose more than one time on an object.: Lines: 95	C:\Development\TvEngine.clean\TVLibrary\TvService\TsCopier.cs	95	TvService
    	Warning	417	CA2202 : Microsoft.Usage : Object 'writer' can be disposed more than once in method 'TsCopier.DoCopy()'. To avoid generating a System.ObjectDisposedException you should not call Dispose more than one time on an object.: Lines: 92	C:\Development\TvEngine.clean\TVLibrary\TvService\TsCopier.cs	92	TvService
    	Warning	418	CA1001 : Microsoft.Design : Implement IDisposable on 'TvCardContext' because it creates members of the following IDisposable types: 'Timer'. If 'TvCardContext' has previously shipped, adding new members that implement IDisposable to this type is considered a breaking change to existing consumers.	C:\Development\TvEngine.clean\TVLibrary\TvService\TvCardContext.cs	40	TvService
    	Warning	419	CA1063 : Microsoft.Design : Provide an overridable implementation of Dispose(bool) on 'TVController' or mark the type as sealed. A call to Dispose(false) should only clean up native resources. A call to Dispose(true) should clean up both managed and native resources.	C:\Development\TvEngine.clean\TVLibrary\TvService\TVController.cs	51	TvService
    	Warning	420	CA2213 : Microsoft.Usage : 'TVController' contains field 'TVController._epgGrabber' that is of IDisposable type: 'EpgGrabber'. Change the Dispose method on 'TVController' to call Dispose or Close on this field.	C:\Development\TvEngine.clean\TVLibrary\TvService\TVController.cs	824	TvService
    	Warning	421	CA1063 : Microsoft.Design : Modify 'TVController.Dispose()' so that it calls Dispose(true), then calls GC.SuppressFinalize on the current object instance ('this' or 'Me' in Visual Basic), and then returns.	C:\Development\TvEngine.clean\TVLibrary\TvService\TVController.cs	824	TvService
    	Warning	428	CA1001 : Microsoft.Design : Implement IDisposable on 'TvServiceThread' because it creates members of the following IDisposable types: 'EventWaitHandle', 'TVController'. If 'TvServiceThread' has previously shipped, adding new members that implement IDisposable to this type is considered a breaking change to existing consumers.	C:\Development\TvEngine.clean\TVLibrary\TvService\Service1.cs	287	TvService

    tvlib:
    Code:
    Warning	367	CA2000 : Microsoft.Reliability : In method 'TvCardCollection.DetectCards()', call System.IDisposable.Dispose on object 'rotEntry' before all references to it are out of scope.	C:\Development\TvEngine.clean\TVLibrary\TVLibrary\Implementations\TvCardCollection.cs	149	TVLibrary
    	Warning	368	CA2000 : Microsoft.Reliability : In method 'TvCardCollection.GetHash(string)', call System.IDisposable.Dispose on object 'new SHA1Managed()' before all references to it are out of scope.	C:\Development\TvEngine.clean\TVLibrary\TVLibrary\Implementations\TvCardCollection.cs	483	TVLibrary
    	Warning	369	CA2000 : Microsoft.Reliability : In method 'TvCardAnalog.BuildGraph()', object '_hauppauge' is not disposed along all exception paths. Call System.IDisposable.Dispose on object '_hauppauge' before all references to it are out of scope.	C:\Development\TvEngine.clean\TVLibrary\TVLibrary\Implementations\Analog\Graphs\Analog\TvCardAnalog.cs	624	TVLibrary
    	Warning	370	CA2213 : Microsoft.Usage : 'ConditionalAccess' contains field 'ConditionalAccess._DigitalDevices' that is of IDisposable type: 'DigitalDevices'. Change the Dispose method on 'ConditionalAccess' to call Dispose or Close on this field.	C:\Development\TvEngine.clean\TVLibrary\TVLibrary\Implementations\DVB\ConditionalAccess\ConditionalAccess.cs	1089	TVLibrary
    	Warning	371	CA2213 : Microsoft.Usage : 'ConditionalAccess' contains field 'ConditionalAccess._TeVii' that is of IDisposable type: 'TeVii'. Change the Dispose method on 'ConditionalAccess' to call Dispose or Close on this field.	C:\Development\TvEngine.clean\TVLibrary\TVLibrary\Implementations\DVB\ConditionalAccess\ConditionalAccess.cs	1089	TVLibrary
    	Warning	372	CA2213 : Microsoft.Usage : 'ConditionalAccess' contains field 'ConditionalAccess._conexant' that is of IDisposable type: 'ConexantBDA'. Change the Dispose method on 'ConditionalAccess' to call Dispose or Close on this field.	C:\Development\TvEngine.clean\TVLibrary\TVLibrary\Implementations\DVB\ConditionalAccess\ConditionalAccess.cs	1089	TVLibrary
    	Warning	373	CA2213 : Microsoft.Usage : 'ConditionalAccess' contains field 'ConditionalAccess._digitalEveryWhere' that is of IDisposable type: 'DigitalEverywhere'. Change the Dispose method on 'ConditionalAccess' to call Dispose or Close on this field.	C:\Development\TvEngine.clean\TVLibrary\TVLibrary\Implementations\DVB\ConditionalAccess\ConditionalAccess.cs	1089	TVLibrary
    	Warning	374	CA2213 : Microsoft.Usage : 'ConditionalAccess' contains field 'ConditionalAccess._genericbdas' that is of IDisposable type: 'GenericBDAS'. Change the Dispose method on 'ConditionalAccess' to call Dispose or Close on this field.	C:\Development\TvEngine.clean\TVLibrary\TVLibrary\Implementations\DVB\ConditionalAccess\ConditionalAccess.cs	1089	TVLibrary
    	Warning	375	CA2213 : Microsoft.Usage : 'ConditionalAccess' contains field 'ConditionalAccess._genpix' that is of IDisposable type: 'GenPixBDA'. Change the Dispose method on 'ConditionalAccess' to call Dispose or Close on this field.	C:\Development\TvEngine.clean\TVLibrary\TVLibrary\Implementations\DVB\ConditionalAccess\ConditionalAccess.cs	1089	TVLibrary
    	Warning	376	CA2213 : Microsoft.Usage : 'ConditionalAccess' contains field 'ConditionalAccess._hauppauge' that is of IDisposable type: 'Hauppauge'. Change the Dispose method on 'ConditionalAccess' to call Dispose or Close on this field.	C:\Development\TvEngine.clean\TVLibrary\TVLibrary\Implementations\DVB\ConditionalAccess\ConditionalAccess.cs	1089	TVLibrary
    	Warning	377	CA2213 : Microsoft.Usage : 'ConditionalAccess' contains field 'ConditionalAccess._isgenericatsc' that is of IDisposable type: 'GenericATSC'. Change the Dispose method on 'ConditionalAccess' to call Dispose or Close on this field.	C:\Development\TvEngine.clean\TVLibrary\TVLibrary\Implementations\DVB\ConditionalAccess\ConditionalAccess.cs	1089	TVLibrary
    	Warning	378	CA2213 : Microsoft.Usage : 'ConditionalAccess' contains field 'ConditionalAccess._isvixsatsc' that is of IDisposable type: 'ViXSATSC'. Change the Dispose method on 'ConditionalAccess' to call Dispose or Close on this field.	C:\Development\TvEngine.clean\TVLibrary\TVLibrary\Implementations\DVB\ConditionalAccess\ConditionalAccess.cs	1089	TVLibrary
    	Warning	379	CA2213 : Microsoft.Usage : 'ConditionalAccess' contains field 'ConditionalAccess._knc' that is of IDisposable type: 'KNCAPI'. Change the Dispose method on 'ConditionalAccess' to call Dispose or Close on this field.	C:\Development\TvEngine.clean\TVLibrary\TVLibrary\Implementations\DVB\ConditionalAccess\ConditionalAccess.cs	1089	TVLibrary
    	Warning	380	CA2213 : Microsoft.Usage : 'ConditionalAccess' contains field 'ConditionalAccess._profred' that is of IDisposable type: 'ProfRed'. Change the Dispose method on 'ConditionalAccess' to call Dispose or Close on this field.	C:\Development\TvEngine.clean\TVLibrary\TVLibrary\Implementations\DVB\ConditionalAccess\ConditionalAccess.cs	1089	TVLibrary
    	Warning	381	CA2213 : Microsoft.Usage : 'ConditionalAccess' contains field 'ConditionalAccess._technoTrend' that is of IDisposable type: 'TechnoTrendAPI'. Change the Dispose method on 'ConditionalAccess' to call Dispose or Close on this field.	C:\Development\TvEngine.clean\TVLibrary\TVLibrary\Implementations\DVB\ConditionalAccess\ConditionalAccess.cs	1089	TVLibrary
    	Warning	382	CA2213 : Microsoft.Usage : 'ConditionalAccess' contains field 'ConditionalAccess._twinhan' that is of IDisposable type: 'Twinhan'. Change the Dispose method on 'ConditionalAccess' to call Dispose or Close on this field.	C:\Development\TvEngine.clean\TVLibrary\TVLibrary\Implementations\DVB\ConditionalAccess\ConditionalAccess.cs	1089	TVLibrary
    	Warning	383	CA2213 : Microsoft.Usage : 'ConditionalAccess' contains field 'ConditionalAccess._winTvCiModule' that is of IDisposable type: 'WinTvCiModule'. Change the Dispose method on 'ConditionalAccess' to call Dispose or Close on this field.	C:\Development\TvEngine.clean\TVLibrary\TVLibrary\Implementations\DVB\ConditionalAccess\ConditionalAccess.cs	1089	TVLibrary
    	Warning	384	CA2213 : Microsoft.Usage : 'TvCardDvbBase' contains field 'TvCardDvbBase.winTvCiHandler' that is of IDisposable type: 'WinTvCiModule'. Change the Dispose method on 'TvCardDvbBase' to call Dispose or Close on this field.	C:\Development\TvEngine.clean\TVLibrary\TVLibrary\Implementations\DVB\Graphs\TvCardDvbBase.cs	1910	TVLibrary
    	Warning	385	CA2215 : Microsoft.Usage : Ensure that method 'TvCardDvbSS2.Dispose()' calls base.'TvCardDvbSS2.Dispose()' in all possible control flow paths.	C:\Development\TvEngine.clean\TVLibrary\TVLibrary\Implementations\DVB\Graphs\SS2\TvCardDvbSS2.cs	1161	TVLibrary
    	Warning	386	CA2000 : Microsoft.Reliability : In method 'RtspStreaming.GetDefGatewayNetAddresses()', call System.IDisposable.Dispose on object 'searcher' before all references to it are out of scope.	C:\Development\TvEngine.clean\TVLibrary\TVLibrary\Streaming\RtspStreaming.cs	375	TVLibrary
    	Warning	387	CA2000 : Microsoft.Reliability : In method 'TeletextPageRenderer.Render(Graphics, byte, int, ref int, ref int, int, int, int)', object 'backBrush' is not disposed along all exception paths. Call System.IDisposable.Dispose on object 'backBrush' before all references to it are out of scope.	C:\Development\TvEngine.clean\TVLibrary\TVLibrary\Teletext\Implementations\TeletextPageRenderer.cs	404	TVLibrary
    	Warning	388	CA2000 : Microsoft.Reliability : In method 'TeletextPageRenderer.Render(Graphics, byte, int, ref int, ref int, int, int, int)', object 'backPen' is not disposed along all exception paths. Call System.IDisposable.Dispose on object 'backPen' before all references to it are out of scope.	C:\Development\TvEngine.clean\TVLibrary\TVLibrary\Teletext\Implementations\TeletextPageRenderer.cs	406	TVLibrary
    	Warning	389	CA2000 : Microsoft.Reliability : In method 'TeletextPageRenderer.Render(Graphics, byte, int, ref int, ref int, int, int, int)', object 'foreBrush' is not disposed along all exception paths. Call System.IDisposable.Dispose on object 'foreBrush' before all references to it are out of scope.	C:\Development\TvEngine.clean\TVLibrary\TVLibrary\Teletext\Implementations\TeletextPageRenderer.cs	405	TVLibrary

    we should get rid of those asap :=)

    you can try the attached ruleset in vs2010.

    I've fixed tvlib and will work on tvservice later.
    will post patch soon.

    /gibman
     

    Attachments

    • idisposable_ruleset.zip
      497 bytes

    mm1352000

    Retired Team Member
  • Premium Supporter
  • September 1, 2008
    21,544
    8,236
    Home Country
    New Zealand New Zealand
    Interesting...

    Just a note that the ConditionalAccess warnings in TVLibrary will be a non-issue. Release.ToNull() (or whatever is called) calls Dispose() on those objects.
     

    mm1352000

    Retired Team Member
  • Premium Supporter
  • September 1, 2008
    21,544
    8,236
    Home Country
    New Zealand New Zealand
    DD CA doesn't need releasing... I *think*. There are no unmanaged memory pointers used for PMT or DiSEqC, so nothing to release except the tuner filter, which is a reference to the TvCardDvbBase tuner filter anyway...
     

    gibman

    Retired Team Member
  • Premium Supporter
  • October 4, 2006
    2,998
    1,372
    Usa
    Home Country
    Ethiopia Ethiopia
    ok, then we should maybe consider removing the idisposable interface on the DD class ??

    /gibman
     

    rlevis

    MP Donator
  • Premium Supporter
  • August 15, 2008
    510
    34
    Home Country
    New Zealand New Zealand
    Okay, sorry for the delay. About to go to bed, but here are 5 more DLLs. I'm beginning to think the issue is possibly in the streaming code...
    mm
    Here are the results.

    epggrabber: LEAK
    heartbeat: LEAK
    pendingdeletions: LEAK
    scheduler: no leak
    streaming: LEAK

    I hope this makes sense.

    I just realized I had a recording scheduled which was recording every time I started a new TVService. I hope that doesn't matter.
     

    miroslav22

    Development Group Member
  • Premium Supporter
  • September 4, 2009
    703
    460
    Warwick
    Home Country
    United Kingdom United Kingdom
    It might be a good idea to use a memory profiler to help with this. I think we have a team licence for one don't we?

    It's not really a reliable way to detect leaks just by monitoring the memory usage over time. The GC runs at undetermined times and doesn't necessarily free all memory that is unused.
     

    mm1352000

    Retired Team Member
  • Premium Supporter
  • September 1, 2008
    21,544
    8,236
    Home Country
    New Zealand New Zealand
    I hope that doesn't matter.
    It certainly does matter. The idea was that TV Server should be completely idle, so starting a recording pretty much throws those results out the window. Are you still able to reproduce the leak if the schedule doesn't start?

    miroslav22: you probably know better than me here... ;)
     

    Users who are viewing this thread

    Top Bottom