Solving SurfaceView Memory leakage and surfaceview Memory leakage

Source: Internet
Author: User

Solving SurfaceView Memory leakage and surfaceview Memory leakage

mSurfaceView.getHolder().getSurface().release();



How to solve the memory leakage problem in mfc

Baidu encyclopedia Memory leakage:
Generally, memory leakage refers to heap memory leakage. Heap memory refers to the memory allocated by the program from the heap, which is of any size (the size of the memory block can be determined during the running period) and must be explicitly released after use. Applications generally use functions such as malloc, calloc, realloc, and new to allocate a block of memory from the heap. after use, the program must call free or delete to release the block, otherwise, the memory won't be used again, so we can say that the memory is leaked.
Memory leakage is a common problem. When a previously allocated piece of memory no longer needs to be used or cannot be accessed, but it is not released, this process will lead to a reduction in the total available memory, memory leakage occurs. Although excellent programming practices can ensure minimal leakage, it is very likely that memory leakage will occur when a large number of functions are used to process the same memory block. This is especially true when an Error Path is encountered.
Reference: Baidu

JAVA Memory leakage

Although the gc policy is used in Java, memory leakage still occurs. Therefore, java also proposes local solutions such as weak references.

However, the System. exit (0) mentioned by the landlord will not cause memory leakage.

Actually, there are two categories of memory. Memory in the upstairs and I started to talk about Java refers to the memory of the Virtual Machine. ing to the host machine can have various implementations, although it is usually mapped to the memory. And System. exit (0) will analyze the virtual machine, that is, to split the virtual machine, it will not be able to talk about the concept of virtual machine memory leakage without leakage. The so-called "no skin, no memory" will be attached. The problem is whether the host machine memory is leaked. In principle, no matter what commands are executed and mapped to the host machine resources when the VM is running, it is released when the host is removed. Of course, in terms of implementation, if the host operating system or JVM has bugs, of course, it may cause memory leakage, but it has nothing to do with the client program written by java programmers. (Supplement: the operating system and java platform are responsible for killing java processes in the host machine. In the old operating system, we often encounter problems such as file not being properly closed, but these problems should not be very serious in the current operating system, that is, the host machine actually has a certain recovery mechanism, including memory recovery, but it is not a memory leak. Memory leakage refers to the memory resource out of control caused by the customer program when the program is running. The problem when the customer program exits is the scope of the operating system design)

Related Article

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.