Looking for breakthrough ideas for innovation challenges? Try Patsnap Eureka!

Method, storage medium, electronic device and system for automatically releasing file resources

An automatic release and file resource technology, applied in resource allocation, program control design, electrical digital data processing, etc., can solve problems such as system exceptions, memory bank leaks, and reduction of available memory space, and achieve the effect of solving memory leaks

Active Publication Date: 2020-07-31
WUHAN DOUYU NETWORK TECH CO LTD
View PDF9 Cites 0 Cited by
  • Summary
  • Abstract
  • Description
  • Claims
  • Application Information

AI Technical Summary

Problems solved by technology

When using files in traditional solutions, we often forget to release the memory space occupied by the files, which can easily lead to "memory leaks" (Memory Leak, that is, the memory hardware resources of the computer are occupied by useless files for a long time, resulting in the loss of available memory. The space is reduced, just like the memory bank is leaked, so the risk of being named "memory leak") appears. Long-term memory leaks may cause system exceptions and cause program crashes
[0003] In the traditional solution, the operation file usually has a file handle, and various abnormal information will be generated during the reading and writing of the file. If the file class holding the file handle does not release the file handle in time or releases an error, this It is very easy to cause file resources to be occupied or the file cannot be opened
[0004] In other words, memory leaks are prone to occur in the traditional file reading and writing process, and the existing file handle method cannot solve these problems well

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, storage medium, electronic device and system for automatically releasing file resources
  • Method, storage medium, electronic device and system for automatically releasing file resources
  • Method, storage medium, electronic device and system for automatically releasing file resources

Examples

Experimental program
Comparison scheme
Effect test

Embodiment 1

[0042] figure 1 It is a schematic diagram of the steps of the method for automatically releasing file resources in the embodiment of the present invention.

[0043] Such as figure 1 As shown, the method for automatically releasing file resources includes the following steps S1 to S5.

[0044] Step S1, setting a file read and write function to perform read and write operations on the file, the read and write function is set as a public type and has a parameter of a file path.

[0045] This step mainly realizes the design and definition of file read and write functions.

[0046] File reading and writing usually involves two aspects of information: the file path filePath, the length information length of the file to be read, and so on.

[0047] Based on the above-mentioned file read and write information, this embodiment designs a file read and write function readFile, and the specific function definition is as follows:

[0048] public static String readFile(String filePath, ...

Embodiment 2

[0101] An electronic device provided by this embodiment will be described in detail below.

[0102] The electronic device includes a memory and a processor, and the memory stores a computer program running on the processor, and is characterized in that: the method for implementing the following steps when the processor executes the computer program:

[0103] Step S1, setting a file read and write function to perform read and write operations on the file, the read and write function is set as a public type and has a parameter of a file path.

[0104] Step S2, verifying the read-write function according to the file path.

[0105] Step S3, after the verification is passed, sub-threads are created to perform read and write operations.

[0106] Step S4, closing the file stream resource information of the file object read in the read-write operation and releasing the memory resource occupied by the file object.

[0107] In step S5, communication is established between the main thr...

Embodiment 3

[0118] The storage medium provided in this example will be described in detail below.

[0119] A storage medium, on which a computer program is stored, is characterized in that: when the computer program is executed by a processor, the method for realizing the following steps is realized:

[0120] Step S1, setting a file read and write function to perform read and write operations on the file, the read and write function is set as a public type and has a parameter of a file path.

[0121] Step S2, verifying the read-write function according to the file path.

[0122] Step S3, after the verification is passed, sub-threads are created to perform read and write operations.

[0123] Step S4, closing the file stream resource information of the file object read in the read-write operation and releasing the memory resource occupied by the file object.

[0124] In step S5, communication is established between the main thread and the sub-thread to obtain the file content information ...

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 automatically releasing file resources, a storage medium, an electronic device and a system, which relate to the field of computer information processing. The method comprises the following steps: a file reading and writing function is set to read and write a file; the read and write function is set to a public type and has a parameter of a file path; the filereading and writing function is set to read and write a file. Verifying the read / write function according to the file path; After the verification is passed, a sub-thread is opened for reading and writing operation; Closing the file stream resource information of the file object read in the read / write operation and releasing the memory resource occupied by the file object; A communication is established between the main thread and the child thread to obtain the file content information read from the child thread. A read-write function is used in the child thread to read and write, and the memory resource occupied by the read file object is cleaned after the read and write is completed, so that the file can be read and written, and the memory resource occupied by the file due to reading a large number of file objects is not caused, and the problem of memory leakage is solved.

Description

technical field [0001] The invention relates to a method for automatically releasing file resources in software memory management, belonging to the field of computer information processing. Background technique [0002] In the development process of Android software, we often use file and other operation functions. File operation involves the application of file resources and the operation of file objects. When using files in traditional solutions, we often forget to release the memory space occupied by the files, which can easily lead to "memory leaks" (Memory Leak, that is, the memory hardware resources of the computer are occupied by useless files for a long time, resulting in the loss of available memory. The space is reduced, just like the memory bank is leaked, so the risk of being named "memory leak") appears, and long-term memory leaks may cause system exceptions and program crashes. [0003] In the traditional solution, the operation file usually has a file handle,...

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 Patents(China)
IPC IPC(8): G06F9/50
CPCG06F9/5016G06F9/5022
Inventor 张磊陈少杰张文明
Owner WUHAN DOUYU NETWORK TECH CO LTD
Who we serve
  • R&D Engineer
  • R&D Manager
  • IP Professional
Why Patsnap Eureka
  • Industry Leading Data Capabilities
  • Powerful AI technology
  • Patent DNA Extraction
Social media
Patsnap Eureka Blog
Learn More
PatSnap group products