Comments (1)
Thanks,
Someone else pointed this out also, I just didn't have time to address it
yet.
I plan to do some major overhauls of the project in the coming months and
will incorporate your fix (or if you want to submit a fix To github I will
merge it in).
Cheers,
Justin
On Wednesday, 15 January 2014, Remco Ros wrote:
Hey,
I don't know if you're still active on this project, but I have been
playing with your code and found a severe memory leak.The Screenshot (MarshalByRefObject) object is never released and it
doesn't implement IDisposable.If capturing a lot of screenshots, memory in the target process keeps
growing.In my case, this resulted in a OOM exception after ~30 seconds of getting
consecutive screenshots.Fix is simple, implement IDisposable, and call
RemotingServices.Disconnect(this).Then, make sure to call Dispose (or the using() construct) in the client
application.public class Screenshot : MarshalByRefObject, IDisposable
{
private bool _disposed;public Screenshot(Guid requestId, byte[] capturedBitmap) { _requestId = requestId; _capturedBitmap = capturedBitmap; } ~Screenshot() { Dispose(false); } /// <summary> /// Disconnects the remoting channel(s) of this object and all nested objects. /// </summary> private void Disconnect() { RemotingServices.Disconnect(this); } [SecurityPermissionAttribute(SecurityAction.Demand, Flags = SecurityPermissionFlag.Infrastructure)] public override object InitializeLifetimeService() { // // Returning null designates an infinite non-expiring lease. // We must therefore ensure that RemotingServices.Disconnect() is called when // it's no longer needed otherwise there will be a memory leak. // return null; //var lease = (ILease)base.InitializeLifetimeService(); //if (lease.CurrentState == LeaseState.Initial) //{ // lease.InitialLeaseTime = TimeSpan.FromSeconds(2); // lease.SponsorshipTimeout = TimeSpan.FromSeconds(5); // lease.RenewOnCallTime = TimeSpan.FromSeconds(2); //} //return lease; } Guid _requestId; public Guid RequestId { get { return _requestId; } } byte[] _capturedBitmap; public byte[] CapturedBitmap { get { return _capturedBitmap; } } public void Dispose() { GC.SuppressFinalize(this); Dispose(true); } protected virtual void Dispose(bool disposing) { if (_disposed) return; Disconnect(); _disposed = true; }
}
Hope that helps.
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/7
.
from direct3dhook.
Related Issues (20)
- Attempt to update image element every frame in d3d11? HOT 4
- Memory leak in hooked application HOT 7
- Question: Interactive UI Overlay HOT 2
- Strange exception HOT 1
- Failed injection in League of Legends HOT 9
- Error in InitialiseHook: System.Runtime.InteropServices.SEHException (0x80004005): External component has thrown an exception. HOT 1
- can I use this for simulate dirext input for games?
- Сhange of path *.dll
- cann't inject wow,error code:93913088 HOT 1
- Screenshot background window HOT 3
- Black screen when capturing from multiple clients HOT 8
- Captures Complete but Do Not Display, Overlay Does Not Display
- Region settings not correct. HOT 1
- Memory leak on screenshot HOT 5
- Memory leak on image draw HOT 2
- I need some help HOT 31
- Memory leak after unreasonable ammount of DrawOverlayInGame calls and large ImageElement HOT 7
- When creating an ImageElement with the "Bitmap bitmap" override, DXHookD3D11 throws an exception HOT 1
- What is CaptureInterface.StartRecording()? HOT 1
- Memory leakage HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from direct3dhook.