[[ header START ]]

Welcome to OS2.GURU site! (eComStation.RU)

Select your language: Russian English Deutch Spanish Italian Portuguese Czech Polish French

Frequently asked questions and answers:
telegram

Форум обсуждение

telegram

Send message

telegram

[ +7-981-8529467 (Санкт-Петербург)

telegram

t.me/os2_guru

eComStation.RU


ru · en · de · es · it · pt · cz · pl · fr
OS/2 is a greatly different operating system for PC (ArcaOS, eComStation, IBM OS/2 Warp)
Applications, news, reviews, support of users, hardware, questions and answers.
 
[What is OS/2?  News  Install  Update  
 
 
Usage  Future  Community  Projects  

How to buy
russian OS/2 apps?

The concept of
OS/2 development

 
Update

 
Applications

 
Advantages:

 
For developer:

 
(Пайпы программ)

 
Companies:

 
History:

 
(Бонусы)

 
Advice:

 
(Барьеры и решения)

 
Technologies:

 
(Применение в науке, лаборатории, ..)

 

 
Solutions

 
New eComStation:

 
Future:

 
(Ссылки на другие сайты)

 
(Картинка дня)

 
OS/2 artefacts:

 
Gadgets:

Upgrade ArcaOS to NeoWPS level

  • Install original PNG icons drawed by designer, specialized at OS/2 adornation.
  • Install eSchemes 2018 to change colors and buttons on desktop.

High Memory usage in OS/2


TITLE: High Memory usage in OS/2

DATE: 2003-07-07 11:13:31

AUTHOR: Evgeny Kotsuba

Please use online translator
go to http://translate.google.com
and request the translation of http://ru.ecomstation./showarticle.php?id=87
to your language

...........

....p.. .........(dz) . .... ..... (. 1997 ....) ..... . ...... ".p..p....p...... . OS/2" [1]

........, ......... ........... ....... . .......

.... .. ...... ........ ................ . DOS - ......, . ...... .. ......... ...... ........ .. .... ..... ........ ...... ........., ....... .. ......... ......, ...... . ....... .. ......... ........ - ... ... ........ ..... ....... . .......... .... .. ......... ... ......., ........ .., ............ ............... ...... ... ................ . ............ ...... . ........... ....... (. . ....... ........... . OS/2) ... ... .......... .. ..... ...... .. ... ..., .... ....... ...... .. ............ . ....... ......... ............ ......... (... ....... ...... OS/2 - ..... 512 .........., . ....... ....... .............. ..........). ........ ... ......... ....., . ..... ..... .. ......... ... ....., ......, ..... ................... ..........:

int fd = open (filename,mode);
long size_of_file = filesize(fd);
char * input = malloc(size_of_file);
read(fd, input, (unsigned) size_of_file);

(.. ........, ... ... - 32-....... ..., . ........ sizeof ........ ......... ....... read ..... 4, ... . ........ long)

.... ..... .. ... .. ..... ......

char * input = malloc(size_of_file); if(input == NULL)
. printf("Error: malloc ......\n");
exit(1);
.

... ... ....... .... ........ .. ........ ....... .......... ...... ........ ......... ........ ..... ............ . ........ ............ . .......... .....

........

. ... ......... ... ..... ....... ......, ..... "....... ...... ............ . ....... ......... ............ .........". . . .... .......... ...... .... ......... .......... .......... ... . ....... ... ....... ....... .........., ... malloc .... .......... ... NULL. ..... .... .. ....... .... ......... ............ maloc/realloc ........ . ....... ............. ............ ...... ... ....... .......... ......... ..... ...... .......... ... ......... .. .......

...... ........ ......... memEat.cpp

......... ........ .. 1 .. ......, ..... ......... NULL .. malloc ....... ......... .. ...... . ........ .. 1k , ..... .......... NULL ....... ...... ......... .. ...... . ........ .. 32 ....., ..... ......... ........ NULL ....... ...... ......... . ....... .. exit(1).

RAM eat:246Mb
RAM eat:247Mb
RAM eat:248Mb
Error1: malloc ......
15675:263.3086Mb:
Error2: malloc ......
5216:263.467804Mb:

........., . ... ......... 512 Mb ?! . ... ......... ......... .. ...... ?!

. ......... .......... ... .....-..... .......: printf & Co .... .......... ...... malloc'.. . . ........ ........ ...... .. ......... . ...... ............. ..... ....... ....... ......... ......... .. ....... (........, ... PM-.........) ........... ....... .. ......., ............ ......., .......... malloc/calloc/realloc, ........... ..............

. ... .. . ...... 512Mb? .......... ...... ..... ......, .... . ..... ......... ....... ..........., .......... ..... ...........

......... ..........

DosQuerySysInfo ............. ... .......... ..... .......... .........., ..... ....... QSV_MAXPRMEM . QSV_MAXSHMEM.

......... ....... ... ......... .......... . ......., ....... ............. ...... DosQuerySysInfo. ... .... .............., ... ........ QSV_MAX ...... ...... ...... ... ...... ...... .... (.. 27 .. 32). ........ ........ ......... DosQuery.cpp . ....... ... ..........:

19 Maximum number of bytes of memory that can be allocated by all processes in the system 529948672

20 Maximum number of bytes of memory that this process can allocate in its private arena. 318111744

21 Maximum number of bytes of memory that a process can allocate in the shared arena. 193331200

19 Maximum number of bytes of memory that can be allocated by all processes in the system 2068279296

20 Maximum number of bytes of memory that this process can allocate in its private arena. 271450112

21 Maximum number of bytes of memory that a process can allocate in the shared arena. 231538688

Revision 14.088 Revision 9.032

..... ....... .. ..... .........., ... ....... malloc/calloc, ....... ...... ........ DosAllocMem, ..... ............ ...... .. ....., ... ....... . QSV_MAXPRMEM(20). ...... . ...... .......... ..... . QSV_MAXSHMEM(21) - ... .. ........... .... ..... .........., .., ........, ... ... ...... ........ ... shared arena, ... ...... ....... ...... ........ ... ......... ....... ..... ........ "............. ......." . ......... ... QSV_TOTAVAILMEM (19) ... ...... ...... OS/2. ..... ...., ......., ... ....... DosQuerySysInfo ... ....... .. ...... QSV_MAX .......... ..... .... ............ .... ... ........... ....... ......... High Memory, .... ..... .. ..... ............ ..... ...... ......

VIRTUALADDRESSLIMIT

VIRTUALADDRESSLIMIT - ..... ...... . CONFIG.SYS ......... . ........... ....., ... ... .. ..... ...... ........ . [5]

A new config.sys parameter, VIRTUALADDRESSLIMIT, has been added to specify the highest virtual memory address that may be accessed. The default value for OS/2 Warp Server for SMP is 2 GB, which is specified in megabytes in the command argument:

VIRTUALADDRESSLIMIT=2048

The smallest value allowed is 512, which provides compatability with previous versions of OS/2 which only allowed access to 512 MB. The largest value supported is 3072 (3 GB). The VIRTUALADDRESSLIMIT parameter may be specified as part of selective install.

Values in excess of 512 will reduce the number of processes that can concurrently run on the system. When memory has been exhausted, OS/2 control program functions will fail with ERROR_NOT_ENOUGH_MEMORY and PM functions will fail with PMERR_INSUFFICIENT_MEMORY.

This information can be found in the SMP programming addendum, shipped as part of the Warp SMP toolkit (SMP.INF).

Warp SMP toolkit . .. ....., . . ....... ....... ....

addendum.inf | 232941 |16/10/00 | 13:14

...... . .... addendum.inf ... ....... ............ . ... ... ... ... ..... ............. .... ...... ............... ...... APIs Supporting High Memory Objects.

......... DosQuery .. ...... . Revision 14.088 . .......... VIRTUALADDRESSLIMIT= 3072 . CONFIG.SYS

26 Number of processors in the machine 1

27 Maximum amount of free space in process's high private arena 2348810240

28 Maximum amount of free space in process's high shared arena 2348810240

29 Maximum number of concurrent processes supported 172

30 Size of the user's address space in megabytes 3072

...., .. ..... ..... ........ ........ ... . ...... ...... ......, ... .. .. ...... ..... ............?

OBJ_ANY: ......... ........

..... ....., ... ..... ........ ...., ... ..... ............ High Memory, ... ... - ... . .. ......... ............, ... ....... Google - ... [7]

(To activate HMS in your application, use the attribute OBJ_ANY with the memory allocation functions!)

APIRET result;
PCHAR lowp = NULL;
ULONG i, size;

size = 1024*1024;
result = DosAllocMem((PPVOID)&lowp,size,
PAG_COMMIT | PAG_WRITE | OBJ_ANY)

\TOOLKIT\H\bsememf.h ........ .........:

#define OBJ_ANY 0x00000400U /* allocate memory anywhere */

. ...... ............. ......... OBJ_ANY .. ...... ..... DosAllocMem ......... ERROR_INVALID_PARAMETER (87). .... .... ..... ............ ... ............ ........... ...... . High Memory.
...., .. ......... ... ......... ........ ...... .. High Memory private arena. ........ ........ ............ .... ..-............

User's heap

..-........... ............ ........ .......... ....... - ... ...... ..... ............. ....... ......... malloc ... .. ......... .................. .........., ....., ..., ........ Squid ... Mesa3d .......... ....... (wrappers) ... ........... .......-......... . .......-......... ........

........:

void * _mesa_malloc(size_t bytes)
.
#if defined(XFree86LOADER) && defined(IN_MODULE)
return xf86malloc(bytes);
#else
return malloc(bytes);
#endif
.

..... ....... ..... ............. ... ....... ... ...... . ....... . ..... ....., . ..... ...... ......... .... ........ ..... malloc .. ...-.. ....... ..... .......... . ............ Visual Age C++, ...... Managing Memory With Multiple Heaps:

VisualAge C++ now gives you the option of creating and using your own pools of memory, called heaps. You can use your own heaps in place of or in addition to the default VisualAge C++ runtime heap to improve the performance of your program. This section describes how to implement multiple user-created heaps using VisualAge C++.

Note: Many readers will not be interested in creating their own heaps. Using your own heaps is entirely optional, and your applications will work perfectly well using the default memory management provided (and used by) the VisualAge C++ runtime library. If you want to improve the performance and memory management of your program, multiple heaps can help you. Otherwise, you can ignore this section and any heap-specific library functions.

...... . ................. ...... ............ ....... .. ......... _umalloc . ....... ... . . EMX .... ........ ([9]). .......... ...... ...... . _umalloc ........ . [8]. . ...... - ........! ...... .......... ............ ....... ...... ........ _ucreate, ....... . ...... ...... . ........... ........ . ..... DosAllocMem ......... ........ OBJ_ANY

#include
Heap_t _ucreate(void *block, size_t initsz, int clean, int memtype,
void *(*getmore_fn)(Heap_t, size_t *, int *)
void (*release_fn)(Heap_t, void *, size_t);

Language Level: Extension

_ucreate creates your own memory heap that you can allocate and free memory from, just like the VisualAge C++ runtime heap.

Before you call _ucreate, you must first get the initial block of memory for the heap. You can get this block by calling an OS/2 API (such as DosAllocMem or or DosAllocSharedMem) or by statically allocating it. (See the CP Programming Guide and Reference for more information on the OS/2 APIs.)
Note: You must also return this initial block of memory to the system after you destroy the heap.

When you call _ucreate, you pass it the following parameters:

  • block The pointer to the initial block you obtained.
  • initsz The size of the initial block, which must be at least _HEAP_MIN_SIZE bytes (defined in). If you are creating a fixed-size heap, the size must be large enough to satisfy all memory requests your program will make of it.
  • clean The macro _BLOCK_CLEAN, if the memory in the block has been initialized to 0, or !_BLOCK_CLEAN, if the memory has not been touched. This improves the efficiency of _ucalloc; if the memory is already initialized to 0, _ucalloc does not need to initialize it.
    • Note: DosAllocMem initializes memory to 0 for you. You can also use memset to initialize the memory; however, memset also commits all the memory at once, an action that could slow overall performance.
  • memtype A macro indicating the type of memory in your heap: _HEAP_REGULAR (regular) or _HEAP_TILED (tiled). If you want the memory to be shared, specify _HEAP_SHARED as well (for example, _HEAP_REGULAR | _HEAP_SHARED). Tiled memory blocks will not cross 64K boundaries, so the data in them can be used in 16-bit programs. Shared memory can be shared between different processes. For more information on different types of memory, see the Programming Guide and the Control Program Guide and Reference.
    • Note: Make sure that when you get the initial block, you request the same type of memory that you specify for memtype.
  • getmore_fn A function you provide to get more memory from the system (typically using OS/2 APIs or static allocation). To create a fixed-size heap, specify NULL for this parameter.
  • release_fn A function you provide to return memory to the system (typically using DosFreeMem). To create a fixed-size heap, specify NULL for this parameter.

If you create a fixed-size heap, the initial block of memory must be large enough to satisfy all allocation requests made to it. Once the block is fully allocated, further allocation requests to the heap will fail. If you create an expandable heap, the getmore_fn and release_fn allow your heap to expand and shrink dynamically.

When you call _umalloc (or a similar function) for your heap, if not enough memory is available in the block, it calls the getmore_fn you provide. Your getmore_fn then gets more memory from the system and adds it to the heap, using any method you choose.

Your getmore_fn must have the following prototype:

void *(*getmore_fn)(Heap_t uh, size_t *size, int *clean);

where:

  • uh Is the heap to get memory for.
  • size Is the size of the allocation request passed by _umalloc. You probably want to return enough memory at a time to satisfy several allocations; otherwise, every subsequent allocation has to call getmore_fn. You should return multiples of 64K (the smallest size that DosAllocMem returns). Make sure you update the size parameter if you return more than the original request.
  • clean Within getmore_fn, you must set this variable either to _BLOCK_CLEAN, to indicate that you initialized the memory to 0, or to !_BLOCK_CLEAN, to indicate that the memory is untouched.

Note: Make sure your getmore_fn allocates the right type of memory for the heap.

When you call _uheapmin to coalesce the heap or _udestroy to destroy it, these functions call the release_fn you provide to return the memory to the system. function.

Your release_fn must have the following prototype:

void (*release_fn)(Heap_t uh, void *block, size_t size);

The heap uh the block is from, the block to be returned, and its size are passed to release_fn by _uheapmin or _udestroy.

For more information about creating and using heaps, see the "Managing Memory" in the Programming Guide.

Return Value: If successful, _ucreate returns a pointer to the heap created. If errors occur, _ucreate returns NULL.

..... ....... . .. . ..... ......., ..... ............ ... .... ...... ......., ....... ........ ....... ... malloc, . ...... ......., ........ ... ............... , . ... ..... ........... ...... .... . ............... (. VAC'.) ............. .......... ....... ....... ..... ........., . ....... ......., realloc . free .... ..... ............, .. ..... .... ............ ...... . .. ...... ..... ........ .. ...... ... . ..... ....... - . ......... ........ ....... ...., ....... .......... ....... printf . ...... . ..... ......., . ...... ............ ...... . ..... ................ ..... .... ......., ... ..-....... .... ......... .. ....... ..... ..... .......... .. ...........

.........., . ... ... ;-). ........ ...... ............

. ....... Mem_OBJ.cpp: ..........(.. .. ..........) 1 .. ......, ..... .......... ... 1 .. , . ....... .. .... ........... fwrite c ......... ... ......... .. High Memory . ..... ........ . ............ . .........

. Memory2.cpp . imports.cpp ........ ...... p......... ...... . High Memory ... ..... . OS/2 Mesa3d.

. .... .......... ............. ........... ...... . High Memory - .... ........... ...., .. ............ _umalloc . DosAllocMem . .......... OBJ_ANY, . ......... ...... - ............ ........... malloc.

..........

.. ......... ........ High Memory . ............ ..........

... ....... .......... . .......... stdlib ..... .. .... ......... .......... .......... ... ...... . High Memory. ... EMX . OpenWatcom'. ... ...... .........

PS. ... ....... ....... ..... ........ . . ....... ..... 4GB .. 32...... ............. ... ..... .... ..... ......... malloc & Co . ........ ....... ... ........... ........... ............ ........ ...... . ......


...... .. ....:

  1. ........ . .p..p....p...... ... OS/2. ............
  2. OS/2 .......: ...... . ....... ....... ......., ....... ......., ... .., #07/1997
  3. The Life Cycle of a Memory Page in OS/2
  4. The OS/2 API Project - DosAllocMem
  5. Frequently Asked Questions OS/2 Warp What is the parameter VIRTUALADDRESSLIMIT in config.sys
  6. os2ddprog/message/2465 -- Scott Garfinkle ........., ... ... VMLock .... ......

    /* Like OBJ_ANY for DosAllocMem -- use
    mem above 512mb line if possible */
    #define VMDHA_USEHMA 0x2000

  7. OS/2 address range . ...... ............. OBJ_ANY .. Frank Meilinger
  8. Example of Using VisualAge Extenstions to Memory Management Functions
  9. Multiple heaps in EMX -- The interface to multiple heaps is more or less compatible to the one of IBM's Visual Age C++ compiler. Definitions and declarations for using multiple heaps are in the header.
  10. ........ ...... . ... .................. ....... . ...... ...... . ..... HighMemory_examples.zip

Test the program:

T&V HappyPlayer - control of TV-tuners Brooktree 848/878

Comments:

Sergey Posokhov
2003-07-07 15:19:16

......., ...... IBM-.. .. ........ .......... ..... DosAllocMem ... . ........, ..... .. ....... ....... ......, ....... ..... .......... ..... ... ....... . .... .............. ....? ..... . .... .....?

LightElf
2003-07-07 16:24:23

... ..... ......., ..... ...... ....., . .... .. ....... . High Memory ...... ..... ...... ...-...... . ..... ........ ............ . ... .... ..... ....... ......-...... 16-....... API. ..... .. ........

Evgeny
2003-07-07 18:41:30

To:LightElf . .. ... .......... ?

Slavik Gnatenko
2003-07-07 20:29:46

"...... . ...... .......... ..... . QSV_MAXSHMEM(21) - ... .. ........... .... ..... ..........". ...... ......... .. shared memory . ...... ........ ........ 256M ............. .. ....... ... ........ .......... .., ... ..... ...... ... ... .... ..... . Theseus ......... ... .. ......... ............ .... ........... ...... . ..... . .... .. .... ..... .... ........... .........

2LightElf: ...... .... .. .... 16.. ........ .. ..... ........ .... ...... ..... ......., .. ... ..... ......... ........ . ..., ... .. ......... ....... ... ............... 32->16 .......... ............. tiling. . .. ....... ......... 512M.

Evgen
2003-07-08 01:54:30

To: Slavik Gnatenko: ... ........ ... ........ 256M ? ... ... . ....., ......... ... ... . ... - ... ... shared mem ........ (..)64M. .

. ....... ...... .. ........ ........ ... Total free space in shared arena = 86M. .... ....... ......... ?

Slavik Gnatenko
2003-07-08 17:14:02

2 Evgen. ... ........ ... .. ...... ..... . debugging handbook.... ....... ... ..... ...... ..., ......... .. ..... . .... ... ... ..... .......... . ..... ........ .....: .... shared memory watermark. ........ .. ....... .......... ..... .. (512-64)M. .... private memory watermark. ........ ..... .......... ......... ............. .......... ..... .. 64M. .. .... ......... ...... ... .......... ......... .... ...... ....... ....... ..... .......... . ........ ....... ...... .. .........., ....... ....... ...... ..... .......... .. ......... .... .......... ...., .. .......... ..... ........ ......... ...... .... ... . .... 86Mb. .. .... . ........ .... ..... .........

Evgeny
2003-07-08 19:48:16

To: Slavik Gnatenko

.. ... ... . ........., .... ...... ... 200.. , .... ... . ... ..... ....... .... ......, ....-.. ... ......., ... ...... ... ... .. .......

VicTor Smirnoff
2003-07-12 15:25:28

.. .. ...... ......... ...... ... DLLBASING=OFF .......

Doodle
2003-07-14 15:27:39

Any chance to read this article in english in the foreseeable future?

I'm quite interested in it.

............
2003-07-15 00:47:06

world.altavista.com will provide you an instant translation

............
2003-07-15 00:47:20

world.altavista.com will provide you an instant and quite readable translation

Evgen
2003-07-15 01:37:11

To: Doodle this article is mainly lirics ;-)

in a nutshell you can look at bin and code of samples in

[url]

Doodle
2003-07-17 16:00:43

thnx to all!

Comment this article.


Your Name:

Your E-Mail:

CODE:
......

  

Your Comment:


How to increase the population of eComStation? Every eCS specialist can setup eCS for own friends and relatives, then print instructions how to use the system LiveBook brochure

Articles

Operating System
Software
Hardware
For developer
Misc
From editor





Last active poll: What is the height of RPM barrier?

[Google]

IBM OS/2 Warp

 
For dummies

Report: OS/2 compatible hardware

 
Reviews


     
  Why eComStation?
Features
Advantages
Usage
Clips and screenshots
   eComStation for
for businessmen
for students and engineers
for reselles of computers
community of users
   Developer
Distribute the program
Description of API, libraries
Start new project
Competition
   Applications
On-line catalogue
Select from eCo Market
   Support service
Contact the web-master
Buy eComStation
Frequently asked questions
for Beginners
 
 
© 2001 - 2021 eCo Software, All rights reserved
Сибирский Медведь технологическая компания
eComStation Serenity Systems International • OS/2 Warp IBM Corporation • ArcaOS Arca Noae