Develop a Video Monitoring System Documentary 7 Callback

Source: Internet
Author: User

In haikang, there is a video function, in which a callback function needs to be registered and then read the content.

I found that after each call, there was no problem for the first time, but after the second call, "try to read or write the protected memory. This usually indicates that other memory is damaged ."

 

The document mentions:

Http://topic.csdn.net/u/20080327/14/fb1b0644-2557-4f0d-a39d-16264b22b490.html

NET is the automatic management of memory, the memory will be automatically recycled
Hikvision's API is implemented by C ++, and C ++ manages the memory by the user.

When executed in the callback function ,. the memory has been recycled in. NET, but you still need to read the memory, and "try to read or write the protected memory" will appear. This usually indicates other memory corruption "error

 

Again, google the secret:

Also, make sure the lifetime of the delegate instance covers the lifetime of the unmanaged code; otherwise, the delegate will not be available after it is garbage-collected.

 

The problem should be that my callback function is put in the class and recycled by the memory .. This is probably the problem. After reading the public code on the internet, others' delegate are all outside the class.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.