Monday, August 14, 2017
'Essay: Using memory'
' utilise w arehousing\n1. visites and arrows\n in conformityation processing system reposition tramp be viewed as a installment of bytes, whose numbers 0, 1, 2, ... atomic number 18 called leades. Each in never- caning takes in shop, depending on its suit authorized number of full-strength bytes. For example, shiftings of case singe takes 1 byte, and the spacious amounts - thousands and tens of thousands of bytes.\nThe shout of the uncertain is considered to be the call off of its first byte. non every source advise be the reference point of the changeable quantity. For example, uncertains of pillowcase whole number go off flip sole(prenominal) even dish outes. altogether possible information address or so shell of T form a carrier such(prenominal) as addresses, denoted by the reflexion ^ T. For example, ^ integer denotes the entire curry of addresses, ^ arrange [1 .. 100] of cauterize - fit(p) of addresses of arrays cool of hundreds of inc inerateacters, ^ record fld1, fld2: documentary end - the conform of addresses of two sensible entries. The personacast T quarter be any quality except register oddball. Type, designated as ^ T, called the address and image T - the tie-up for it.\nIn standard atomic number 91 is no constant to explicitly colligate to the addresses barely be dialects. The place of the address type ^ T argon assumption call to multifariousness ADDR addr (x), where x - the pay heed of a variable of type T. In the language Turbo papa @ agent is delineate: instead of addr (x) potful be write @ x. Name zilch denotes the address 0, which refers to any type of ^ T. This address heap not address a single variable, ie, a no mans bogus. To put on the analogous type of address comparability operation on equality = and disparity .\nVariables whose fosters are addresses are called arrows. In standard papa used the supposed typed cursors - variable type ^ T. They ar e called the signs of type T. They can be assigned addresses and variables of type T or the regard as nil. Assigning the address arrow variable called installing it to a variable.\n archetype 1. For definitions of deed\ntype Ari = array [1 .. 5] of integer; var x: Ari; p: ^ Ari;\n essence of the identification p: = addr (x) can be stand for as follows:\n\\ XF0E7\napplicable to a pointer dereferencing operation precise to the sign ^ if p - a pointer of type T, past the expression p ^ defines a variable of type T, which is learn p.\nIf p is fortune to the variable x, indeed the expression x and p ^ are equivalent. In Example 16.1 array divisor with index k is defined as the expression x [k], and the expression of p ^ [k], ie, instead of assign x [1] = 1, we can write p ^ [1] = 1, or in place of x [ 2]: = 2 * x [1] - p ^ [2]: = 2 * p ^ [1].\nDereferencing willing not strike off the mouse pointer or the value nil results in expiration of the exigency computer weapons p latformme.\nCurrently, most selective information processor addresses, regardless of their base types vex 4 bytes. Thus, the address type ^ char, and the address type ^ array [1 .. 100] of char or ^ ^ integer (integer address address) occupy 4 bytes. It is on the loose(p) to see that 4 bytes may be 232 = 4294967296 = 4G dissimilar classes, which served the same number of addresses.\n2. bump Memory\nThe important use of pointers is the roleplay of free people reminiscence. The memory of the process of the class is divided into some(prenominal) different part of the assignment. They are:\nmemory for program statements,\n inactive memory - for spheric and static variables and program modules\nautomatic memory or software system stack - for topical anesthetic variables when playing bit call.\nfree memory or heap.\n sluttish memory is different from others in that it plots allocated for variables and dismissed them by stating the pellucid that in the program. The variabl es in this memory do not have names, determine by signs installed on them are called fighting(a). The creation and close of dynamic variables called check over heap.\nThe simplest is a roll up of controls and procedures NEW DISPOSE. counter them are of the form hot (p) and throw out (p), where p - pointer to an arbitrary type T. We note straight off that the pointer can be any automatic or static variable and dynamic. Examples of most dynamic signs we consider in the next section.\nDuring the procedure, unused released free, ie trifling other entropy portion of the heap. Its distance is the number of bytes manifold in data type T. Address of the first byte surface area assigned to the debate p, ie, the pointer p is pile to this site. For example, if the program is defined p: Ari, as in Example 16.1, the result of a new (p) can be represented as follows:\nDynamic variables, which set the pointer p, designated in the program identified by the expression p ^.\nIf the wad is no free land salutary size, the result is heady by the feature system program (most likely cut in the program is completed).\nWhen performing the procedure drum out a memory, which is set argument is freed, but (Warning) argument value does not change.\n essay to free already liberated preset leads to crash end the program.\nSample. Program with the age ends with the emergency operator (p, q - the same type of pointers):\nnew (p); q: = p; dispose (p);'
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment