Closed jpuerj closed 1 year ago
Is there a typo in your copy of ImagePut?
Line 1362 should read GlobalLock, not GlobalAlloc.
Sorry, that's a typo in the topic, the file is correct! Going to edit it!
Can you check for a memory leak? It looks like one to me. See how much memory AutoHotkey is using in task manager - it should be stable.
Also can you post the full code? Are you deleting 'img'?
Also,
ImagePutBuffer("window")
is ambiguous syntax try:
ImagePutBuffer({window: "MyTitle"})
to avoid the bug where a file name has the same name as a window
Can you check for a memory leak?
It increased 10MB in the last 3 minutes, I'm going to keep an eye on it. I had discarded this possibility earlier because when I got a leak in the past it would crash very early. EDIT: look's like a leak, it increased 30MB since writting this post.
Are you deleting 'img'?
I'm not deleting image. I thought it was not needed because it's inside a class method.
Also can you post the full code?
Sure: script.zip
I'm going to try deleting 'img' and every related object. I just need img := ""
, right?
Thanks!
Well this doesn't look like an ImagePut error.
Try to improve your memory management:
fn(img) {
filepath := "something.png"
static search := Imageputbuffer(filepath)
img.imagesearch(search)
}
Make the search images static so you don't create a million of them. Then I see you're storing the screen capture in an array, you'll need to do arr[123] := "" to delete them. (Don't bother deleting static images they will be cleaned on script exit)
You probably didn't notice, but it will have to hit a few gigs of ram until it crashes like above.
Add documentation to delete the buffers
Also, add an update() method to Imageputbuffer (for screen capture only)?
The problems seems to be with ImageSearch
. Whenever the function is called the memory use increase a bit. I tested on this hotkey:
F1:: { static img := ImagePutBuffer("Code") static search := ImagePutBuffer("images/waypoint_1.png") loop { xy := img.ImageSearch(search) Sleep(100) } }
The increase is very small... About 1MB each minute... I think that's why it took more than an hour to crash on my script.
Fixed by af2bca4d69010a86eb4eb2e20964996f5188071e 44a25c805a326135f2f2b30e4a7d7a420b13e8c9 and 2fbc4fe122ade19e3f6dfc2aad9b256be680e61a.
Hello!
First of all, thank you for this project, it's amazing!
I have a script that uses
ImagePut
to update information about a window every 200ms. The update function is something like this:updateInfo() { img := ImagePutBuffer("window") this.getInfoX(img) this.getInfoY(img) this.getInfoZ(img) }
The
getInfo
functions mainly check pixel colors at different locations.After about 1 hour of running the script I always get this error: