CN109324842A - Asset creation method, storage medium, device and method needed for program starts - Google Patents

Asset creation method, storage medium, device and method needed for program starts Download PDF

Info

Publication number
CN109324842A
CN109324842A CN201710640036.XA CN201710640036A CN109324842A CN 109324842 A CN109324842 A CN 109324842A CN 201710640036 A CN201710640036 A CN 201710640036A CN 109324842 A CN109324842 A CN 109324842A
Authority
CN
China
Prior art keywords
memory
program
need
currently
creation
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
CN201710640036.XA
Other languages
Chinese (zh)
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.)
Wuhan Douyu Network Technology Co Ltd
Original Assignee
Wuhan Douyu Network 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 Wuhan Douyu Network Technology Co Ltd filed Critical Wuhan Douyu Network Technology Co Ltd
Priority to CN201710640036.XA priority Critical patent/CN109324842A/en
Publication of CN109324842A publication Critical patent/CN109324842A/en
Pending legal-status Critical Current

Links

Classifications

    • 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/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44557Code layout in executable memory
    • 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/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44505Configuring for program initiating, e.g. using registry, configuration files

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Devices For Executing Special Programs (AREA)

Abstract

The present invention relates to computer software fields, asset creation method, storage medium, device and method needed for a kind of program starts are disclosed, this method includes S1: the calling constructed fuction interface of initialization distribution object memory headroom interface and memory address;S2: apply for a memory headroom in the global static storage area of memory;S3: byte-aligned setting is carried out to the memory headroom of application and forms Coutinuous store space;S4: when program starts, according to the operating status that need to currently use object, judgement need to currently use whether object has been created, if it is not, S5 is then gone to, if so, obtaining the pointer of the object;S5: judgement need to currently use whether object is creating, if so, waiting the Object Creation to complete, if it is not, object need to currently be used by then creating in the memory headroom of application.To the repetition application of memory and the generation of memory fragmentation when the present invention can effectively reduce Object Creation, promotes program and start speed.

Description

Asset creation method, storage medium, device and method needed for program starts
Technical field
The present invention relates to computer software fields, and in particular to asset creation method, storage needed for a kind of program starts are situated between Matter, device and method.
Background technique
Program in the operating systems such as Windows, iOS, Android is during starting, it will usually which it is a variety of right to create As resource is to carry out initial work when program starting, but the object created at this time is in heap memory, easily formation heap Memory fragmentation, and then the starting speed of program and the access speed to the corresponding interface are influenced, meanwhile, some does not need to be stood Carving the object used can also be created, so that the use of object resource be caused to waste, influence the runnability of program, further Reduce the starting speed of program.
Summary of the invention
In view of the deficiencies in the prior art, asset creation needed for starting the purpose of the present invention is to provide a kind of program Method promotes program and starts speed, this hair to the repetition application of memory and the generation of memory fragmentation when effectively reducing Object Creation It is bright that a kind of required asset creation system of sequence starting is also provided, memory headroom can be reduced and repeat to apply, effectively promotion program starts Speed.
To achieve the above objectives, the technical solution adopted by the present invention is that, comprising:
S1: the calling constructed fuction interface of initialization distribution object memory headroom interface and memory address;
S2: by distribution object memory headroom interface, apply for a memory headroom in the global static storage area of memory;
S3: byte-aligned setting is carried out using memory headroom of the compiler to application and forms Coutinuous store space;
S4: program start when, according to currently need to use object operating status, judgement currently need to use object whether by Creation, if it is not, S5 is then gone to, if so, obtaining the pointer of the object;
S5: judgement need to currently use whether object is creating, if so, the Object Creation is waited to complete, and obtain The pointer of the object, if it is not, then calling the calling constructed fuction of memory address to create in the memory headroom of application need to currently make With object, and obtain the pointer of the object of creation.
Based on the above technical solution, in S3, the memory headroom of application is configured according to 32 byte-aligned forms.
Based on the above technical solution, the object for being created and having created is respectively positioned on global static The memory headroom of memory block application.
Based on the above technical solution,
The operating status of the object is judged according to the access interface status information of object;
The access interface status information is identified by denotation of variable;
The denotation of variable includes not creating, creating neutralization creation completion.
Based on the above technical solution, it in S5, when need to currently object be used to create, be then allowed by thread It walks function yieldCurrentThread and waits the creation completion that need to currently use object.
The present invention also provides a kind of storage medium, computer program, the computer program are stored on the storage medium Above-mentioned method is realized when being executed by processor.
Asset creation equipment needed for starting the present invention also provides a kind of program, including memory and processor, on memory The computer program run on a processor is stored, the processor realizes above-mentioned side when executing the computer program Method.
Asset creation system needed for starting the present invention also provides a kind of program characterized by comprising
Initialization module, the calling constructed fuction for being used to initialize distribution object memory headroom interface and memory address connect Mouthful;
Module is obtained, is used to apply in the global static storage area of memory by distribution object memory headroom interface One memory headroom, meanwhile, byte-aligned setting is carried out using memory headroom of the compiler to application and forms Coutinuous store space;
Judgment module is used for when the program is started, and judgement need to currently use the operating status of object;
Execution module is used for the judging result based on judgment module, if need to currently object be used to be created, obtains The pointer of the object waits the Object Creation to complete, and obtain the finger of the object if need to currently object be used to create Needle calls the calling constructed fuction of memory address to create in the memory headroom of application if need to currently object be used not create Object need to be currently used, and obtains the pointer of the object of creation.
Based on the above technical solution, the acquisition module is also used to the memory of application according to 32 byte-aligned shapes Formula is configured.
Based on the above technical solution, when need to currently object be used to create, be then given way letter by thread Number yieldCurrentThread, which is waited, currently need to use the creation of object to complete.
Compared with the prior art, the advantages of the present invention are as follows: during the compiling of program, i.e., deposited in the global static state of memory Storage area is one memory headroom of creation application of object in advance, and the creation of subsequent object is completed in the memory headroom of application, It avoids program starting from creating the duplicate application for carrying out memory when object, reduces the starting time of program indirectly, meanwhile, work as object When needing, judgement need to currently use whether object has been created, if having created, then be used directly, if not creating, wait wound Completion or directly creation are built, to reach the reuse effect of object resource, the time loss for repeating to create object is avoided, reaches To the purpose promoted to program starting speed.
Detailed description of the invention
Fig. 1 is the flow chart of asset creation method needed for a kind of program of the present invention starts;
Fig. 2 is the structural schematic diagram of asset creation equipment needed for a kind of program of the present invention starts.
Specific embodiment
Invention is further described in detail with reference to the accompanying drawings and embodiments.
Shown in Figure 1, the embodiment of the present invention provides a kind of asset creation method needed for program starts, for pair The creation of required object, the program of the embodiment of the present invention open when program starts in the operating systems such as Windows, iOS, Android Asset creation method needed for dynamic is suitable for the creation of all objects when program starts, such as the creation of foo object, foo are objects A common mathematical function name in resource.Asset creation method needed for program of the invention starts specifically includes:
S1: the calling constructed fuction interface of initialization distribution object memory headroom interface and memory address.By this step, Object can be prevented to execute static initialization operation automatically, to facilitate subsequent better control that need to currently use making by oneself for object Adopted creation process.
S2: by distribution object memory headroom interface, apply for a memory headroom in the global static storage area of memory.Institute The actual creation amount of the memory headroom size of application required object when being run according to program carries out flexible choice.By global quiet As soon as pre- first to file piece memory headroom in state memory block, because the memory of static storage area has been distributed during program compiling At, pre- one memory of first to file in global static storage area in advance before program starting, makes calling program in starting at this time It does not just need to apply for memory again again in the process, to efficiently reduce the application number of object memory in program start-up course Amount.
S3: byte-aligned setting is carried out using memory headroom of the compiler to application and forms Coutinuous store space.It is preferred that The memory headroom of application is configured by ground according to 32 byte-aligned forms, while the memory headroom after setting being made to meet POD spy Property, that is, the memory headroom after being arranged is one section of continuous memory space.Accordingly it is arranged by the memory headroom to application, it can To effectively reduce the memory fragmentation of heap, guarantee the safe and effective of subsequent object static initialization, the object for effectively promoting creation is real The performance of example.In memory, usually arrange that 32 byte-aligned forms are according to the alignment form of 8 one lattice of byte The arrangement mode of 32 one lattice of byte particularly utilizes built-in command _ _ declspec (align (Foo)) of compiler, _ _ Alignof (Foo) is configured the memory of application according to 32 byte-aligned forms.
By the above process, i.e., to Object Creation when required memory headroom be optimized, to effectively subtract Apply for the time consumed by a large amount of memories when few program starting, the starting speed of program is effectively promoted.
S4: program start when, according to currently need to use object operating status, judgement currently need to use object whether by Creation, if it is not, then going to S5, if so, obtaining the pointer of the object, the creation speed and performance of object are optimal feelings at this time Condition.When program starts, i.e., the operating status of object needed for program starting is judged, judge current desired object whether It is created, avoids repetition from creating object and further increase the starting speed of program to save object creation time.
S5: judgement need to currently use whether object is creating, if so, the Object Creation is waited to complete, and obtain The pointer of the object, the creation speed and performance of object are taken second place at this time, if it is not, the calling constructed fuction of memory address is then called to exist Object need to currently be used by creating in the memory headroom of application, and obtain the pointer of the object of creation.
Program object required when starting is multiple, it is therefore desirable to carry out successively single judgement to required object, go forward side by side Row, which is waited accordingly, creates or used etc., to be operated.
When need to currently object be used not to be created also, pass through atomic operation _ InterlockedCompareExchange Quickly to judge currently use whether object is creating, if need to currently object be used to create, pass through Thread concession function yieldCurrentThread, which is waited, currently need to use the creation of object to complete.
The pointer of object passes through instance function and is obtained.
Be created and the object that is creating be respectively positioned on memory headroom in global static storage area application, i.e., by Creation is creating in the space memory for neutralizing and applying before the object that creation is completed is respectively positioned on, and meets the quick creation of object Demand.
The operating status of object judges according to the access interface status information of object, i.e., according to the access interface state of object Information judges the operating status of object, specifically judges currently use object by _ InterlockedExchange function Operating status;Access interface status information is identified by denotation of variable;Denotation of variable has been created including not creating, creating neutralization At.
When below in conjunction with program starting, the coding process of the creation of foo object is exemplified below:
The principle of asset creation method needed for program of the invention starts is, during the compiling of program, by point It defines and is arranged with object memory headroom interface initialization, be in advance the creation application one of object in the global static storage area of memory Memory headroom, and applied memory headroom is accordingly arranged, the creation of subsequent object is in the memory headroom of application It completes, avoids program starting from creating the duplicate application for carrying out memory when object, while decreasing the generation of heap memory fragment, Meanwhile when object needs, judgement need to currently use whether object has been created, if having created, then be used directly, if not creating It builds, then etc. completion to be created or directly creates, to reach the reuse effect of object resource, avoid repeating creation object Time loss achievees the purpose that starting speed to program is promoted, meanwhile, the object that the creation and creation of object are completed is respectively positioned on Shen In memory headroom please, i.e. the corresponding instantiation operation of delay object, then to object on the memory headroom of pre- first to file Creation carries out instantiation operation.Meanwhile under the premise of guaranteeing the access safety of the thread for creating object, it is using operation The atomic operation of system waits the thread for creating object, guarantees the responsiveness of thread to greatest extent, improves program Runnability.
Asset creation method needed for corresponding above procedure starts, the embodiment of the present invention also provide a kind of storage medium, thereon It is stored with computer program, can be realized when which is executed by processor needed for the program starting in the various embodiments described above The step of asset creation method.It should be noted that the storage medium includes USB flash disk, mobile hard disk, ROM (Read-Only Memory, read-only memory), RAM (Random Access Memory, random access memory), magnetic or disk etc. it is each Kind can store the medium of program code.
In addition, shown in Figure 2, asset creation method needed for corresponding program starts, the embodiment of the present invention also provides one kind Asset creation equipment needed for program starts, including memory, processor and storage can be run on a memory and on a processor Computer program, which can realize resource wound needed for program in the various embodiments described above starts when executing computer program The step of construction method.
Resource wound needed for starting the present invention also provides a kind of program for starting required asset creation method based on above procedure Build system, comprising: initialization module obtains module, judgment module and execution module.
Initialization module is used to initialize the calling constructed fuction interface of distribution object memory headroom interface and memory address; Module is obtained to be used to apply for a memory headroom in the global static storage area of memory by distribution object memory headroom interface, Meanwhile byte-aligned setting is carried out using memory of the compiler to application and forms Coutinuous store space;Judgment module is for working as When program starts, judgement need to currently use the operating status of object;Execution module is used for the judging result based on judgment module, if Need to currently object be used to be created, then obtain the pointer of the object, if need to currently object be used to create, waiting should Object Creation is completed, and obtains the pointer of the object, if need to currently object be used not create, calls the calling structure of memory address Object need to currently be used by making function and creating in the memory headroom of application, and obtain the pointer of the object of creation.
Wherein, module is obtained to be also used to be configured the memory of application according to 32 byte-aligned forms.Meanwhile executing mould Block is also used to then wait by thread concession function yieldCurrentThread when need to currently object be used to create Currently the creation of object need to be used to complete.
The principle of asset creation system needed for program of the invention starts is: module is obtained during the compiling of program, It is arranged by being defined to distribution object memory headroom interface initialization, is in advance the wound of object in the global static storage area of memory One memory headroom of application is built, and applied memory headroom is accordingly arranged, the creation of subsequent object is in application It deposits in space and completes, avoid program starting from creating the duplicate application for carrying out memory when object, while it is broken to decrease heap memory The generation of piece, meanwhile, when object needs in use, judgment module judgement need to currently use whether object has been created, if Creation, then be used directly, if not creating, etc. completion to be created or directly creation, to reach the reuse of object resource Effect avoids the time loss for repeating to create object, achievees the purpose that starting speed to program is promoted.
The present invention is not limited to the above-described embodiments, for those skilled in the art, is not departing from Under the premise of the principle of the invention, several improvements and modifications can also be made, these improvements and modifications are also considered as protection of the invention Within the scope of.The content being not described in detail in this specification belongs to the prior art well known to professional and technical personnel in the field.

Claims (10)

1. a kind of asset creation method needed for program starts characterized by comprising
S1: the calling constructed fuction interface of initialization distribution object memory headroom interface and memory address;
S2: by distribution object memory headroom interface, apply for a memory headroom in the global static storage area of memory;
S3: byte-aligned setting is carried out using memory headroom of the compiler to application and forms Coutinuous store space;
S4: when program starts, according to the operating status that need to currently use object, judgement need to currently use whether object is created It builds, if it is not, S5 is then gone to, if so, obtaining the pointer of the object;
S5: judgement need to currently use whether object is creating, if so, waiting the Object Creation to complete, and it is right to obtain this The pointer of elephant, if it is not, then call the calling constructed fuction of memory address created in the memory headroom of application currently need to use pair As, and obtain the pointer of the object of creation.
Asset creation method needed for 2. a kind of program as described in claim 1 starts, it is characterised in that: in S3, application it is interior Space is deposited to be configured according to 32 byte-aligned forms.
Asset creation method needed for 3. a kind of program as described in claim 1 starts, it is characterised in that: it is described be created and The object created is respectively positioned on the memory headroom in global static storage area application.
Asset creation method needed for 4. a kind of program as described in claim 1 starts, it is characterised in that:
The operating status of the object is judged according to the access interface status information of object;
The access interface status information is identified by denotation of variable;
The denotation of variable includes not creating, creating neutralization creation completion.
Asset creation method needed for 5. a kind of program as described in claim 1 starts, it is characterised in that: in S5, needed currently When being created using object, then object need to currently be used by being waited by thread concession function yieldCurrentThread Creation is completed.
6. a kind of storage medium, computer program is stored on the storage medium, it is characterised in that: the computer program is located Reason device realizes method described in any one of claim 1 to 5 when executing.
7. a kind of program starts required asset creation equipment, including memory and processor, store on memory in processor The computer program of upper operation, it is characterised in that: the processor realizes claim 1 to 5 when executing the computer program Described in any item methods.
Asset creation system needed for 8. a kind of program starts characterized by comprising
Initialization module is used to initialize the calling constructed fuction interface of distribution object memory headroom interface and memory address;
Module is obtained, is used for through distribution object memory headroom interface, is applied in one in the global static storage area of memory Space is deposited, meanwhile, byte-aligned setting is carried out using memory headroom of the compiler to application and forms Coutinuous store space;
Judgment module is used for when the program is started, and judgement need to currently use the operating status of object;
Execution module is used for the judging result based on judgment module, if need to currently object be used to be created, it is right to obtain this The pointer of elephant waits the Object Creation to complete, and obtain the pointer of the object if need to currently object be used to create, If need to currently object be used not create, the calling constructed fuction of memory address be called to create in the memory headroom of application currently Object need to be used, and obtains the pointer of the object of creation.
Asset creation system needed for 9. a kind of program as claimed in claim 8 starts, it is characterised in that: the acquisition module is also It is configured for the memory to application according to 32 byte-aligned forms.
Asset creation system needed for 10. a kind of program as claimed in claim 8 starts, it is characterised in that: currently need using When object is creating, then the creation that need to currently use object is waited by thread concession function yieldCurrentThread It completes.
CN201710640036.XA 2017-07-31 2017-07-31 Asset creation method, storage medium, device and method needed for program starts Pending CN109324842A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710640036.XA CN109324842A (en) 2017-07-31 2017-07-31 Asset creation method, storage medium, device and method needed for program starts

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710640036.XA CN109324842A (en) 2017-07-31 2017-07-31 Asset creation method, storage medium, device and method needed for program starts

Publications (1)

Publication Number Publication Date
CN109324842A true CN109324842A (en) 2019-02-12

Family

ID=65245696

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710640036.XA Pending CN109324842A (en) 2017-07-31 2017-07-31 Asset creation method, storage medium, device and method needed for program starts

Country Status (1)

Country Link
CN (1) CN109324842A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111782561A (en) * 2020-09-07 2020-10-16 新华三半导体技术有限公司 SRAM storage space allocation method, device and chip

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5590327A (en) * 1993-03-30 1996-12-31 Lucent Technologies Inc. Method for making data objects having hidden pointers persistent
CN101271428A (en) * 2008-02-25 2008-09-24 北京理工大学 Apparatus and method for object data storage management
CN101339535A (en) * 2008-08-21 2009-01-07 金蝶软件(中国)有限公司 Method and device for monitoring application program performance
CN103902260A (en) * 2012-12-25 2014-07-02 华中科技大学 Pre-fetch method of object file system

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5590327A (en) * 1993-03-30 1996-12-31 Lucent Technologies Inc. Method for making data objects having hidden pointers persistent
CN101271428A (en) * 2008-02-25 2008-09-24 北京理工大学 Apparatus and method for object data storage management
CN101339535A (en) * 2008-08-21 2009-01-07 金蝶软件(中国)有限公司 Method and device for monitoring application program performance
CN103902260A (en) * 2012-12-25 2014-07-02 华中科技大学 Pre-fetch method of object file system

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
KEVIN ZHANG: "内存操作那些事", 《HTTP://WWW.ZYH1690.ORG/MEMORY-OPERATION/》 *
张云临: "内存和对象内存池技术在网游开发中的注意点和应用", 《HTTPS://WWW.CNBLOGS.COM/ZHANGYUNLIN/ARCHIVE/2009/02/23/6167953.HTML》 *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111782561A (en) * 2020-09-07 2020-10-16 新华三半导体技术有限公司 SRAM storage space allocation method, device and chip

Similar Documents

Publication Publication Date Title
KR101971389B1 (en) Federation-based memory management
CN103207797A (en) Capsule type custom-made updating method based on unified extensible firmware interface firmware system
EP2834744B1 (en) System and method for memory management
CN111752571A (en) Program upgrading method, device, equipment and storage medium
CN105373434B (en) resource management system and method
CN106528065B (en) A kind of thread acquisition methods and equipment
CN114610294B (en) Concurrent computation control method and device for efficiency indexes of simulation experiment and computer equipment
CN109558329A (en) A kind of program detecting method, device, equipment and readable storage medium storing program for executing
CN115617364B (en) GPU virtualization deployment method, system, computer equipment and storage medium
CN104731614A (en) Method and device for accelerating data loading in starting process
CN109324842A (en) Asset creation method, storage medium, device and method needed for program starts
CN112965755B (en) Initialization method and device of multi-core processor, electronic equipment and storage medium
US10467027B1 (en) Dynamic script loading resource files
CN110413328A (en) A kind of PXE function enabled method, device and the relevant device of network interface card port
CN109165037A (en) A kind of program online updating method and system based on serial ports processor
Rubini et al. Scheduling analysis from architectural models of embedded multi-processor systems
CN112487092A (en) Intelligent contract calling method and device based on block chain
CN101799793B (en) Flash memory control method and device
US8694975B2 (en) Programming system in multi-core environment, and method and program of the same
EP3134815B1 (en) Memory efficient thread-level speculation
CN103714511B (en) GPU-based branch processing method and device
JP4158458B2 (en) Information processing apparatus and information processing method
GB2611964A (en) Managing asynchronous operations in cloud computing environments
CN106294143A (en) The adjustment method of the depositor of chip and device
CN109375991B (en) Method and system for transforming single process into multiple processes

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
RJ01 Rejection of invention patent application after publication

Application publication date: 20190212

RJ01 Rejection of invention patent application after publication