c# - GetOracleDecimal Memory Leak -
@ GilSlit posted T:
"Well, we come to the disbelief (ODP (.net 2.0) for more than a year after fighting with a memory leak in GetOracleDecimal (in the code we supplied to a customer) ... Good luck! "- GilShalit August 27, 2009 12:44 am < / P>
We are a service that asks the Oracle database every few minutes which is not being released Remember; After using some WinDbg check It turns out that this type is being stored in the queue in the final form: Oracle.DataAccess.Types.OpoDecCtx.
This is the line I think is the problem:
< Pre>decimal volume = (decimal) OracleDecimal.SetPrecision (reader.GetOracleDecimal (5), 28);
I commented on this and the memory leak disappeared.
Any ideas will be appreciated - thanks!
OracleDecimal
type holds a reference < Called Code> OpoDecCtx implements OpoDecCtx for an example of an inner class IDisposable
(because it is self-referencing unmanaged memory), but when it does not apply OracleDecimal IDisposable, You will have to wait for garbage collector to free the underlying unmanaged memory. You can see all these tools, such as using NAT reflectors.
Although it technically "physical" memory leak (memory is eventually released), it does not really give me a lot of problems when you examples of OracleDecimal type that Oracle only Aidiispojebl does not materialize, it is a simple thing ...
anyway, I suggest that you make some hooks work themselves, using reflection:
public Code (Oracleidum OD) // An extension method Build (if (Oracleidicum opodectcx == blank) {// cache data / // get internal field information of OracleDecimalOpoDecCtx = typeof (OracleDecimal) .GetField ("m_opoDecCtx", BindingFlags.Instance | BindingFlags.NonPublic);} IDisposable Disposable = OracleDecimalOpoDecCtx.GetValue (od) as IDisposable; if (disposable! = nULL) {Dispojlkdijaan ();}} private static Fildinfo Orakldekel Opodektiti;}
and you use it would like:
OracleDecimal od = reader.GetOracleDecimal (5); decimal quantity = (d Mlv) OracleDecimal.SetPrecision (od, 28); Od.Dispose ();
Comments
Post a Comment