Eureka AIR delivers breakthrough ideas for toughest innovation challenges, trusted by R&D personnel around the world.

Method and device for preventing memory leakage, and computer readable storage medium

A technology of memory leaks and objects, which is applied in computing, memory systems, program control devices, etc., can solve problems such as memory leaks of external classes, undetermined execution time of threads, and inability to ensure immediate execution of threads, etc., to avoid memory leaks The effect of the leak

Active Publication Date: 2020-12-01
CHINA MOBILEHANGZHOUINFORMATION TECH CO LTD +1
View PDF15 Cites 0 Cited by
  • Summary
  • Abstract
  • Description
  • Claims
  • Application Information

AI Technical Summary

Problems solved by technology

When a thread is submitted to the thread pool for use, it is not guaranteed that the thread will be executed immediately. Even if the thread is executed immediately, it may be because the thread involves time-consuming input / output (I / O) operations, resulting in a time-consuming thread execution. Unsure, in this way, the external class held by the Runnable object cannot be released, resulting in a memory leak of the external class

Method used

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
View more

Image

Smart Image Click on the blue labels to locate them in the text.
Viewing Examples
Smart Image
  • Method and device for preventing memory leakage, and computer readable storage medium
  • Method and device for preventing memory leakage, and computer readable storage medium
  • Method and device for preventing memory leakage, and computer readable storage medium

Examples

Experimental program
Comparison scheme
Effect test

Embodiment Construction

[0020] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention more clear, various implementation modes of the present invention will be described in detail below in conjunction with the accompanying drawings. However, those of ordinary skill in the art can understand that, in each implementation manner of the present invention, many technical details are provided for readers to better understand the present application. However, even without these technical details and various changes and modifications based on the following implementation modes, the technical solutions claimed in this application can also be realized.

[0021] The first embodiment of the present invention relates to a method for preventing memory leaks. The core of this embodiment is to wrap the Runnable object to be executed in the external class with a weak reference, and add it to the thread pool to be executed, thereby decoupling the Runnable object to ...

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to View More

PUM

No PUM Login to View More

Abstract

The invention discloses a method for preventing memory leakage, which comprises the following steps of customizing a static executable object, and realizing a Runnable interface by the static executable object; transmitting at least one first Runnable object to be executed into the static executable object by using a proxy mode to perform weak reference packaging to obtain a packaged second Runnable object; customizing a strong reference queue, and after the first Runnable object is packaged, inserting the first Runnable object into the strong reference queue; submitting the packaged second Runnable object to a thread pool to wait for execution; and when a target thread in the thread pool starts to be executed, deleting a first Runnable object corresponding to a second Runnable object executed by the target thread in the strong reference queue. The invention further provides a device for preventing memory leakage and a computer readable storage medium. According to the memory leakage prevention method provided by the invention, the reference of the Runnable object to the external class can be decoupled, and the memory leakage of the external class is avoided.

Description

technical field [0001] The embodiments of the present invention relate to the technical field of memory performance optimization, and in particular, to a method, device, and computer-readable storage medium for preventing memory leaks. Background technique [0002] In the prior art, Java applications are all based on multi-threading. To use multi-threading, you must define the main Runnable class of the thread. When the main Runnable class used is defined as an internal class, the Runnable object will hold a reference to the external class. . When a thread is submitted to the thread pool for use, it is not guaranteed that the thread will be executed immediately. Even if the thread is executed immediately, it may be because the thread involves time-consuming input / output (I / O) operations, resulting in a time-consuming thread execution. Unsure, in this way, the external class held by the Runnable object cannot be released, resulting in a memory leak of the external class. C...

Claims

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to View More

Application Information

Patent Timeline
no application Login to View More
IPC IPC(8): G06F8/30G06F9/448G06F9/50G06F9/54G06F12/02
CPCG06F8/315G06F9/4492G06F9/5016G06F9/546G06F12/0253G06F2209/548Y02D10/00
Inventor 万竹青马姗姗许剑琪陈斌
Owner CHINA MOBILEHANGZHOUINFORMATION TECH CO LTD
Who we serve
  • R&D Engineer
  • R&D Manager
  • IP Professional
Why Eureka
  • Industry Leading Data Capabilities
  • Powerful AI technology
  • Patent DNA Extraction
Social media
Eureka Blog
Learn More
PatSnap group products