Method and apparatus for requesting use of memory

A memory and memory information technology, applied in the field of resource management, can solve problems such as memory leaks, increased program complexity, and low resource utilization

Pending Publication Date: 2019-01-04
BEIJING JIAXUN FEIHONG ELECTRIC CO LTD
View PDF3 Cites 0 Cited by
  • Summary
  • Abstract
  • Description
  • Claims
  • Application Information

AI Technical Summary

Problems solved by technology

[0005] (1) When a circular reference occurs, a smart pointer based on reference counting will cause a memory leak
[0006] (2) Resource release needs to wait until the reference count is 0 before releasing, and the resource utilization rate is low
[0007] (3) Increase the complexity of the program, and the positioning process is complicated when a memory leak occurs

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 apparatus for requesting use of memory
  • Method and apparatus for requesting use of memory
  • Method and apparatus for requesting use of memory

Examples

Experimental program
Comparison scheme
Effect test

Embodiment 1

[0049] see figure 1 A flow chart of a method for applying and using memory is shown, the method is applied to task threads, and the task threads include task allocation threads and task processing threads, specifically including the following steps:

[0050] S101. Send a resource application request to the resource pool to trigger the resource pool to allocate memory;

[0051] Specifically, the task allocation thread receives a user request and applies for memory from the resource pool.

[0052] S102. Receive memory information sent by the resource pool, where the memory information includes at least a memory identifier and a memory address;

[0053] Wherein, the memory identifier can be a 64-bit integer ID, and the ID is only valid within the life cycle of the resource. The ID is incremented by 64 bits to ensure that the ID is not repeated in the software running cycle.

[0054] For example, the resource pool returns the memory whose ID is 100 and whose address is 0x123400...

Embodiment 2

[0064] see figure 2 A flow chart of a memory application and usage method is shown, the method is applied to a resource pool, and specifically includes the following steps:

[0065] S201. Receive a resource application request sent by the task thread, allocate memory to the task thread and send memory information, where the memory information includes at least a memory identifier and a memory address;

[0066] S202. Receive a resource usage request sent by the task thread, and detect whether the memory is valid;

[0067] If valid, execute step S203

[0068] S203. Send resource availability information to the task thread, so as to trigger the task thread to use the memory.

[0069] The resource release request sent by the task thread is received, the memory is released, and release success information is sent to the task thread.

[0070] If invalid, execute step S204.

[0071] S204. Send resource invalidation information to the task thread.

Embodiment 3

[0073] For the memory application and use method provided in the foregoing embodiments, the embodiment of the present invention provides a memory application and use device, see image 3 A structural block diagram of a device for applying for memory is shown, the device is applied to task threads, and includes the following parts:

[0074] The application module 31 is configured to send a resource application request to the resource pool, so as to trigger the resource pool to allocate memory;

[0075] A receiving module 32, configured to receive memory information sent by the resource pool, where the memory information includes at least a memory identifier and a memory address;

[0076] A detection module 33, configured to send a resource usage request to the resource pool, so as to trigger the resource pool to detect whether the memory is valid;

[0077] The use module 34 is configured to receive resource availability information sent by the resource pool if valid, and use t...

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 provides a method and a device for applying and using a memory, which utilizes the interaction of a task thread and a resource pool to realize the calling of the memory by the thread, the memory can be recovered and reused immediately after the memory is released, thereby improving the resource use efficiency, and eliminating the memory leakage problem caused by the reference counting circular reference. By accessing memory via ID, the possibility of using wild pointer is eliminated. The method and apparatus are convenient for counting memory usage and providing a means to optimize applications.

Description

technical field [0001] The present invention relates to the technical field of resource management, in particular to a memory application and use method and device. Background technique [0002] At present, in multi-threaded programming, the use of resources generally uses reference counting and garbage collection to use resources. [0003] For example, with the introduction of smart pointers in C++, programmers no longer need to worry about where to release the created memory is more appropriate. For example, when a resource is shared by multiple threads, the programmer needs to trigger the release of the pointer by the last thread that does not use the pointer when the life cycle of all modules ends. [0004] However, everything is not perfect, and smart pointers still have certain defects: [0005] (1) When a circular reference occurs, a smart pointer based on reference counting will cause a memory leak. [0006] (2) Resource release needs to wait until the reference 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
Patent Type & Authority Applications(China)
IPC IPC(8): G06F12/14G06F9/50
CPCG06F9/5016G06F12/1416
Inventor 任广磊
Owner BEIJING JIAXUN FEIHONG ELECTRIC 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
Try Eureka
PatSnap group products