CN113342565A - 一种防止内存泄漏的方法及系统 - Google Patents

一种防止内存泄漏的方法及系统 Download PDF

Info

Publication number
CN113342565A
CN113342565A CN202110713831.3A CN202110713831A CN113342565A CN 113342565 A CN113342565 A CN 113342565A CN 202110713831 A CN202110713831 A CN 202110713831A CN 113342565 A CN113342565 A CN 113342565A
Authority
CN
China
Prior art keywords
memory
app
data center
center
data
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110713831.3A
Other languages
English (en)
Inventor
邓良基
肖志颖
欧杰
梁维博
王建军
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhuhai Feisen Power Technology Co ltd
Original Assignee
Zhuhai Feisen Power Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhuhai Feisen Power Technology Co ltd filed Critical Zhuhai Feisen Power Technology Co ltd
Priority to CN202110713831.3A priority Critical patent/CN113342565A/zh
Publication of CN113342565A publication Critical patent/CN113342565A/zh
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/0703Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation
    • G06F11/0706Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation the processing taking place on a specific hardware platform or in a specific software environment
    • G06F11/073Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation the processing taking place on a specific hardware platform or in a specific software environment in a memory management context, e.g. virtual memory or cache management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/0703Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation
    • G06F11/079Root cause analysis, i.e. error or fault diagnosis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3003Monitoring arrangements specially adapted to the computing system or computing system component being monitored
    • G06F11/3037Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system component is a memory, e.g. virtual memory, cache
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3051Monitoring arrangements for monitoring the configuration of the computing system or of the computing system component, e.g. monitoring the presence of processing resources, peripherals, I/O links, software programs
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5016Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Quality & Reliability (AREA)
  • Computing Systems (AREA)
  • Software Systems (AREA)
  • Health & Medical Sciences (AREA)
  • Mathematical Physics (AREA)
  • Biomedical Technology (AREA)
  • Debugging And Monitoring (AREA)
  • Storage Device Security (AREA)

Abstract

本发明提供了一种防止内存泄漏的方法及系统,属于信息技术领域;包括:监视中心单独占用一个进程,与数据中心进行实时数据交互;监视中心定时扫描查询数据中心的当前内存使用情况;数据中心向监视中心反馈APP调用及访问内存的情况;通过限定APP访问/申请内存的方式,通过数据中心统一管理、分配内存,所有APP对内存的使用都要经过数据中心,取消传统的各APP通过全局变量申请各自的内存独立使用的方法,解决内存泄漏的问题。

Description

一种防止内存泄漏的方法及系统
技术领域
本发明涉及信息技术领域,具体为一种防止内存泄漏的方法及系统。
背景技术
现大多数处理中,多进程运行时,各自进程的APP访问/申请内存时大多为通过全局变量单独访问/单独申请、单独使用,并无相关的监控机制。如果存在不合法内存地址或APP实际使用内存大小超过其调用内存大小,容易发生内存泄漏的情况,从而造成宕机或其他出错信息,但却很难查询出错位置,虽然已有查询内存出错位置的诸多相关专利,但实际应用较少,所以最好的处理方法还是从根源上解决问题,防止内存泄漏的可能性。
发明内容
针对上述存在的技术不足,本发明的目的是提供一种防止内存泄漏的方法及系统,通过限定APP访问/申请内存的方式,通过数据中心统一管理、分配内存,所有APP对内存的使用都要经过数据中心,取消传统的各APP通过全局变量申请各自的内存独立使用的方法,解决内存泄漏的问题。
为解决上述技术问题,本发明采用如下技术方案:
一种多app数据交互的实现方法,其特征在于,包括:监视中心单独占用一个进程,与数据中心进行实时数据交互;
监视中心定时扫描查询数据中心的当前内存使用情况;
数据中心向监视中心反馈APP调用及访问内存的情况。
一种多app数据交互的系统,其特征在于,包括:
数据中心,作为所有数据交互的数据池,控制APP及监视中心的相关进程;
监视中心,单独占用一个进程,与数据中心进行实时数据交互。
优选地,扫描间隔设定10ms。
本发明的有益效果在于:1、通过加入数据中心作为中间控制,并加入头、尾的特殊字符校验块,能更好的控制内存的使用和掌握内存的去向,在内存出错时能第一时间找到并定位出错位置;2、能在内存泄漏的源头即禁止,防止内存泄漏后程序依旧不合理运行从而造成死机、重启等重大错误,更有效的避免了程序的出错,提高程序运行的可靠性;3、双向监测的机制更牢靠:数据中心主动向监视中心反馈出错信息并停用出错APP;监视中心定时查询当前数据中心的内存使用情况,如有异常则停出错APP,确保内存在泄漏瞬间即受到控制,避免失控。
附图说明
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1为本发明实施例提供的一种防止内存泄漏的方法及系统的APP使用内存的流程框图;
图2为为本发明实施例提供的一种防止内存泄漏的方法及系统的结构框图;
图3为数据中心处理APP内存申请的处理结构图。
具体实施方式
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。
一种多app数据交互的实现方法,包括:监视中心单独占用一个进程,与数据中心进行实时数据交互;
监视中心定时扫描查询数据中心的当前内存使用情况,扫描间隔设定10ms;
数据中心向监视中心反馈APP调用及访问内存的情况。
一种多app数据交互的系统,其特征在于,包括:
数据中心,作为所有数据交互的数据池,控制APP及监视中心的相关进程;
监视中心,单独占用一个进程,与数据中心进行实时数据交互。
监视中心定时扫描及数据中心查询APP调用内存是否出错的原理如下:
在APP进行内存申请时,会向数据中心发出申请内存的请求,数据中心接收到来自APP的请求后,会通过malloc将需要的内存整理出来,然后主动在整理出来的内存块(如附图3的“APP申请内存块”)头、尾位置加上特殊字符校验块(如附图3中“特殊字符校验块”所示),将整块与申请该内存的APP绑定,但是数据中心返回给APP的内存地址指针仍然为“APP申请内存块”的首地址,“特殊字符校验块”不参与APP内存操作,当APP操作的内存为合法时,“特殊字符内存块”会一直保持当前数据不更改,当APP操作的内存不合法时,如操作内存越界,“特殊字符内存块”数据将被改写,此时数据中心会检测到此行为并将报错信息返送监视中心,如果数据中心因偶然因素未能检测变动,监视中心的定时查询(定时查询间隔设定为10ms)也会发现此问题,从而将使用出错的“特殊字符内存块”所在内存块的APP停用,不允许该APP的启动。
APP使用内存的过程如附图1所示:
数据中心控制APP的启停,当数据中心对APP有启动需求时,会给APP发送开启信号,APP接收到开启信号后,会将该APP启动所需内存告知数据中心,数据中心根据APP返回的信息,判断当前数据中心中是否有足够的内存给APP进行启动,如果存在越界行为,则不允许该APP启动,如果申请的内存在可给予范围,数据中心会进行前面所述的增加内存校验块的操作,然后再允许APP启动。APP启动后,在正常运行过程中如果有访问内存的操作,仍然需要向数据中心发送请求而不能直接进行访问,数据中心获取请求后会判断该APP要访问的内存是否合法(如是否野指针、是否超限越限总内存大小、是否为可访问地址等),如果合法,则将访问内存的内容返回给APP,如果不合法,则不允许访问并将报错信息通知监视中心。
多个APP进行内存申请/访问时同理,但需根据APP申请/访问的先后进行内存的控制。当为申请内存时:前一APP申请内存出错时,该APP禁止启动,数据中心在完成禁止启动动作并报送监视中心后,再处理后一APP的内存申请,即前一APP申请内存出错不应影响后一APP的内存申请;当为访问内存时:前一APP访问内存出错时,等待数据中心完成禁止该APP的内存访问并报送监视中心的处理后,再处理后一APP的内存访问,即前一APP访问内存出错不应影响后一APP的内存访问。
显然,本领域的技术人员可以对本发明进行各种改动和变型而不脱离本发明的精神和范围。这样,倘若本发明的这些修改和变型属于本发明权利要求及其等同技术的范围之内,则本发明也意图包含这些改动和变型在内。

Claims (3)

1.一种多app数据交互的实现方法,其特征在于,包括:监视中心单独占用一个进程,与数据中心进行实时数据交互;
监视中心定时扫描查询数据中心的当前内存使用情况;
数据中心向监视中心反馈APP调用及访问内存的情况。
2.一种多app数据交互的系统,其特征在于,包括:
数据中心,作为所有数据交互的数据池,控制APP及监视中心的相关进程;
监视中心,单独占用一个进程,与数据中心进行实时数据交互。
3.如权利要求1所述的一种多app数据交互的实现方法,其特征在于,扫描间隔设定10ms。
CN202110713831.3A 2021-06-25 2021-06-25 一种防止内存泄漏的方法及系统 Pending CN113342565A (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110713831.3A CN113342565A (zh) 2021-06-25 2021-06-25 一种防止内存泄漏的方法及系统

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110713831.3A CN113342565A (zh) 2021-06-25 2021-06-25 一种防止内存泄漏的方法及系统

Publications (1)

Publication Number Publication Date
CN113342565A true CN113342565A (zh) 2021-09-03

Family

ID=77478895

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110713831.3A Pending CN113342565A (zh) 2021-06-25 2021-06-25 一种防止内存泄漏的方法及系统

Country Status (1)

Country Link
CN (1) CN113342565A (zh)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5953530A (en) * 1995-02-07 1999-09-14 Sun Microsystems, Inc. Method and apparatus for run-time memory access checking and memory leak detection of a multi-threaded program
US20080072007A1 (en) * 2006-06-22 2008-03-20 Dspave Digital Signal Processing And Control Engineering Gmbh Method and computer programming product for detecting memory leaks
CN105094710A (zh) * 2015-09-06 2015-11-25 国电南瑞科技股份有限公司 基于哈希表的单进程动态存储管理方法
CN108377292A (zh) * 2018-01-30 2018-08-07 努比亚技术有限公司 解决内存泄露的方法、终端、服务器及计算机存储介质
US10635578B1 (en) * 2017-11-10 2020-04-28 Amdocs Development Limited System, method, and computer program for periodic memory leak detection
CN112395106A (zh) * 2020-11-17 2021-02-23 努比亚技术有限公司 进程管理方法、移动终端以及计算机可读存储介质

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5953530A (en) * 1995-02-07 1999-09-14 Sun Microsystems, Inc. Method and apparatus for run-time memory access checking and memory leak detection of a multi-threaded program
US20080072007A1 (en) * 2006-06-22 2008-03-20 Dspave Digital Signal Processing And Control Engineering Gmbh Method and computer programming product for detecting memory leaks
CN105094710A (zh) * 2015-09-06 2015-11-25 国电南瑞科技股份有限公司 基于哈希表的单进程动态存储管理方法
US10635578B1 (en) * 2017-11-10 2020-04-28 Amdocs Development Limited System, method, and computer program for periodic memory leak detection
CN108377292A (zh) * 2018-01-30 2018-08-07 努比亚技术有限公司 解决内存泄露的方法、终端、服务器及计算机存储介质
CN112395106A (zh) * 2020-11-17 2021-02-23 努比亚技术有限公司 进程管理方法、移动终端以及计算机可读存储介质

Similar Documents

Publication Publication Date Title
US5499342A (en) System for dynamically switching logical sessions between terminal device and a processor which stops its operation to another working processor under control of communication control processor
KR100575497B1 (ko) 내고장성 컴퓨터 시스템
US7039779B2 (en) Access monitor and access monitoring method for monitoring access between programs
US20010007148A1 (en) Multi-processor system, disk controller using the same and nondisruptive maintenance method thereof
US9286108B2 (en) Method to track application context and application identification
WO1994003855A1 (en) Method for managing resources allocated in a computer
US5875341A (en) Method for managing interrupt signals in a real-time computer system
CN103580891A (zh) 一种数据同步的方法、系统及服务器
CN112486694B (zh) 一种基于Redis的网络锁处理方法及设备
KR20000023497A (ko) 플래시 메모리를 구비한 마이크로컴퓨터 및 플래시메모리에 프로그램을 저장하는 방법
JPH1153202A (ja) 並列トランザクション処理システム
CN112130923A (zh) 容器的管理方法、装置、电子设备及计算机可读存储介质
US8671248B2 (en) Architecture support of memory access coloring
US6865636B1 (en) Multitasking processor system for monitoring interrupt events
CN113342565A (zh) 一种防止内存泄漏的方法及系统
RU99120288A (ru) Способ и устройство для выполнения с высокой надежностью одним процессором нескольких функций с различным уровнем критичности
US20190095193A1 (en) System version upgrading method and apparatus
KR101710328B1 (ko) 동적 재구성 및 교체를 지원하는 os 보안 커널 시스템 및 그 방법
US8689206B2 (en) Isolating operating system in-memory modules using error injection
CN103093529A (zh) 动态刷新数据的方法
US20230409391A1 (en) Thread priority adjusting method, terminal, and computer-readable storage medium
CN115168307A (zh) 支持断点续传的数据同步方法、系统、设备及存储介质
CN115221528A (zh) 可信度量方法、可信度量装置、图像形成装置及存储介质
CN112230949A (zh) 终端软件升级方法、装置、电子设备及存储介质
US6397243B1 (en) Method and device for processing several technical applications each provided with its particular security

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination