System and method for solving memory leak in proxy mode

A technology of memory leakage and proxy mode, applied in the field of Java, can solve the problems of memory leakage of objectA and objectB objects, inconvenient to write code, and objectA objects cannot be released in time.

Active Publication Date: 2019-11-15
贵阳语玩科技有限公司
View PDF9 Cites 2 Cited by
  • Summary
  • Abstract
  • Description
  • Claims
  • Application Information

AI Technical Summary

Problems solved by technology

But this solution will reduce the convenience of writing code. In development, it is often necessary to write an anonymous inner class, which is a kind of non-static inner class. If you want to change the anonymous inner class to a static inner class, you can write code. inconvenient
[0003] such as As shown in Figure 1, objectA is a leaked memory object, its type is OuterClass, which represents the outer class, and InnnerClass is its non-static inner class; objectB object is strongly referenced by objectA object, and at the same time holds OuterClass through privacy The method of this reference strongly references the objectA object; just this will not cause memory leaks. The most important thing is that objectB is strongly referenced by an object objectC with a longer life cycle. When the objectA object needs to be released, because the objectC object The life cycle of objectA is stronger than that of objectA. At the same time, the objectC object indirectly strongly references the objectA object through the path of objectC-objectB-objectA, so that the objectA object cannot be released in time, resulting in memory leaks in the memory of objectA and objectB objects.

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
  • System and method for solving memory leak in proxy mode
  • System and method for solving memory leak in proxy mode

Examples

Experimental program
Comparison scheme
Effect test

Embodiment Construction

[0025] The present invention will be described in detail below in conjunction with specific embodiments.

[0026] The present invention firstly provides a system for solving memory leaks with proxy mode, which includes:

[0027] A judging module: judging two non-static inner classes (the first non-static inner class and the second non-static inner class) that have a strong reference relationship, at least one of which is a non-static inner class with a long life cycle, For example, the first non-static inner class is a non-static inner class with a long life cycle;

[0028] A proxy module: used to insert a proxy non-static internal class between two non-static internal classes;

[0029] A strong reference setting module: set a strong reference relationship between a non-static internal class with a long life cycle (such as the first non-static internal class) and a proxy non-static internal class;

[0030] A weak reference setting module: set a weak reference relationship be...

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 system and method for solving memory leak by using an agent mode, and the system comprises a judgment module which is used for judging two non-static internal classes with astrong reference relation, wherein at least one non-static internal class is a non-static internal class with a long life cycle; an agent module is used for inserting an agent non-static internal class between the two non-static internal classes; a strong reference setting module used for setting a strong reference relationship between a non-static internal class and an agent non-static internalclass with a long life cycle; and a weak reference setting module used for setting a weak reference relationship between the agent non-static internal class and the other non-static internal class except the non-static internal class with the long life cycle. The mutual strong reference of the external class and the internal class is relieved by utilizing the agent mode and the weak reference object, so that the writing convenience of the non-static internal class is kept.

Description

technical field [0001] The invention relates to the technical field of Java, in particular to a system and a method for solving memory leaks by using a proxy mode. Background technique [0002] In Java, non-static inner classes can cause memory leaks. The general solution is to change non-static inner classes to static inner classes. But this solution will reduce the convenience of writing code. In development, it is often necessary to write an anonymous inner class, which is a kind of non-static inner class. If you want to change the anonymous inner class to a static inner class, you can write code. inconvenient. [0003] Such as figure 1 As shown, objectA is a leaked memory object, its type is OuterClass, which represents the outer class, and InnnerClass is its non-static inner class; Refer to the objectA object; just this will not cause memory leaks. The most important thing is that objectB is strongly referenced by an object objectC with a longer life cycle. When the ...

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
Patent Type & Authority Applications(China)
IPC IPC(8): G06F11/07
CPCG06F11/073G06F11/0793
Inventor 卢林清唐进段凌云
Owner 贵阳语玩科技有限公司
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
Try Eureka
PatSnap group products