⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wpw_wapi_mem_95.html

📁 VC programing
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<HTML>
<HR><A NAME=WINAPI_PROG_MEMORY>
Return to <a href="wpw_wapi_index.html#TOC">Table of Contents for this chapter</a><br>
<H4>Subject: Removing a program from memory</H4><PRE>
In article <alastair.11.00121603@dbnonline.co.za>
           alastair@dbnonline.co.za "Alastair Wilson" writes:

>I'm trying to remove a program from memory that has stopped functioning 
>normally. The trouble is when using a FreeModule(hInstance) the programs 
>terminates, but causes and application error. Why? Is there a better way to do 
>this?

Call the "TerminateApp" API in "TOOLHELP.DLL".

Chris
-- 
--------------------------------------------------------------------------
| Chris Marriott, Warrington, UK      | Author of SkyMap v2 shareware    |
| chris@chrism.demon.co.uk            | astronomy program for Windows.   |
|      For more info, see http://www.winternet.com/~jasc/skymap.html     |
|      Author member of Association of Shareware Professionals (ASP)     |
--------------------------------------------------------------------------
 
 </PRE>


<HR><A NAME=WINAPI_MEMORY_ALLOCATION_Q>
Return to <a href="wpw_wapi_index.html#TOC">Table of Contents for this chapter</a><br>
<H4>Subject: Basic Memory Allocation Question</H4><PRE>
In article <jad21-1906951111470001@128.253.145.66> jad21@cornell.edu (Jerry Dumblauskas) writes:

>I'm more familiar with the Mac way of allocating RAM, so please forgive
>newbiness of my Q.  My Q is: how do you need account for RAM in the IBM
>world when choosing applications?  For example, if I want to run Delphi
>(needs a min of 6MB) on top of Windows 95 (supposedly needs 8MB) how much
>RAM do I need on my machine, 14MB?  TIA :)

Memory is a lot more fluid in Windows.  You don't have the fixed-size 
application partitions the Mac uses, and you always have virtual memory 
available (unless you turn it off).  So you don't really add up memory numbers 
like that and say that's how much RAM you need.

The 8Mb figure for Win95 is what it takes to run Win95 *and* some 
reasonable-sized applications.  I don't know, but I suspect the 6Mb quoted for 
Delphi is a minimum total system RAM, assuming you're running under Win31.

If that's the case, then Delphi would certainly run under Win95 on an 8Mb 
system.  It would be very likely that it would run faster on a 16Mb system, 
because you would not have to swap out to disk as much (or at all).

A general rule of thumb for application development is that you can get by 
with 8Mb--barely--but you will be a lot happier with 16 or more.

-Mike
</PRE>

<HR><A NAME=WINAPI_MEMORY_LARGE>
Return to <a href="wpw_wapi_index.html#TOC">Table of Contents for this chapter</a><br>
<H4>Subject: large mode app</H4><PRE>
In article <3s0sfl$4fc@sgi.iunet.it> mcxxxx@mclink.it writes:

> I compiled an application with large model, and I can have only one
> instance of it.
> Why ?
> 
> Thanks in advance,
>    Vincenzo
> 

Here is a quote from a source that may help:

"There are two memory models, large and huge, for compiling a module
that generates far addresses for both code and data references. In
the large memory model, far pointers can be incremented only within
the 64K offset range of a segment. In the huge memory model, far
pointers can be incremented across 64K boundaries, causing both the
segment address and the offset to be incremented. Also, if a module
is compiled with the large memory model, Windows will be able to load
only one instance of the module.

Ideally, a Windows application will use the medium model, and the
size of its modules will be 8K or less. The module that initializes
the application should be marked PRELOAD and DISCARDABLE in the .DEF
file. The module that processes the message queue should be marked
PRELOAD. All other modules should be marked LOADONCALL and
DISCARDABLE. An application that follows these guidelines will start
faster and consume fewer system resources."

Regards,

    Jonnathon :-)

-- 

</PRE>


<HR><A NAME=WINAPI_MEMORY_LARGE_MULTI_INSTANCE>
Return to <a href="wpw_wapi_index.html#TOC">Table of Contents for this chapter</a><br>
<H4>Subject: Multiple instance of large mode app</H4><PRE>
In article <3rvjbs$mkm@vixen.cso.uiuc.edu> rhedin@prairienet.org (Rick Hedin) writes:
>
>Hello.  In Programming Windows, Mr. Petzold seems to say that 
>if you make a large mode program, only one instance will be able 
>to run at a time, and your data blocks will all be fixed, 
>not moveable.  It seems to me that in protected mode, going through 
>the descriptor table will solve the problem.  And in my experiments, 
>I can make as many instances as I like.  Is Petzold wrong here?  
        Yes, he is wrong - many of the comments in the memory management
        chapter were based on specific older versions of the Microsoft
        compiler and Windows 3.0, so don't believe everything.  You
        can use large model and have multiple instances with all compilers
        today.
-- 
John A. Grant                                           jagrant@emr1.emr.ca
Airborne Geophysics
Geological Survey of Canada, Ottawa

</PRE>


<HR><A NAME=WINAPI_MEMORY_MALLOC_A_LOT>
Return to <a href="wpw_wapi_index.html#TOC">Table of Contents for this chapter</a><br>
<H4>Subject: Locating the system resources</H4><PRE>
In article <199506181610.MAA06112@laurel.us.net> mgoelzer@us.net (Mike Goelzer) writes:
>        I'm trying to write a windows program that allocates memory
>for, creates, and then uses a really big linked list.  We're talking
>4-8 MEGABYTES of heap space here.  Now The target machines are 
>capable of handling this, but my problem is that the list will
>probably consist of 50K items.  The project is still in the design
>phase, but I just read in one of my many Windows programming
>books the following statement which concerns me a great deal:
>
>"Suballocators exist because no 16-bit protected mode program
>can ask the system for more than 8,192 memory allocations.  IOW,
>on any one system, only 8192 pointers can be requested from the operating 
>environment at any one time.  This means that if your
>program makes 8,000 allocations in a linked list, all other programs on the 
>system only habe 192 allocations available to them."
>       (from _Teach Yourself Win. Programming_ by Charlie Calver)
>
>Oh shit!  My linked list will require way more than 8K pointers.
>What can I do?  Does anyone have any code (or even abstract
>suggestions) about how to deal with the need for 50,000
>pointers in a linked list at one time?
>
>-mike
>
>Mike Goelzer
><mgoelzer@us.net>

        Don't panic.  Notice the first few words of your quote "Suballocators
        exist because...".  His comments about the limit of 8192 selectors
        are true if you are using GlobalAlloc, which uses 1 selector each
        time.  However, these functions are relatively obsolete except
        for a few circumstances and you can now use malloc/new.  Not only
        does your code look more 'normal', you can take advantage of the
        subsegment allocation that is built in by all (most?) compiler
        vendors.  I believe that memory is grabbed in 4kb chunks and sub
        allocated from that, so that each malloc doesn't necessarily use
        up a selector.

        Keep in mind that you need to use huge pointers & long subscripts
        with contiguous large blocks of memory.  A linked list shouldn't
        require any special treatment, though.
-- 
John A. Grant                                           jagrant@emr1.emr.ca
Airborne Geophysics
Geological Survey of Canada, Ottawa

<HR>
Mike Goelzer (mgoelzer@us.net) wrote:
: Oh shit!  My linked list will require way more than 8K pointers.
: What can I do?  Does anyone have any code (or even abstract
: suggestions) about how to deal with the need for 50,000
: pointers in a linked list at one time?

You might not like my suggestion, but we have had to do something
like this in the past. We (actually my boss) wrote a memory manager
that used GlobalAlloc to get a large chunk of memory and then
would sub-allocate the memory as needed.

AFAIK This is the only way to do what you want.

Chris
 
--
----------------------------------------------------------------------
Chris Reynolds - http://www.cc.gatech.edu/people/home/chrisr Team OS/2

"I believe OS/2 is destined to be the most important operating
system, and possibly program, of all time" - Bill Gates, Microsoft

<HR>
On 18 Jun 1995 11:18:14 -0500, mgoelzer@us.net (Mike Goelzer) said in article <199506181610.MAA06112@laurel.us.net>:

>"Suballocators exist because no 16-bit protected mode program
>can ask the system for more than 8,192 memory allocations.  IOW,
>on any one system, only 8192 pointers can be requested from the operating 
>environment at any one time.  This means that if your
>program makes 8,000 allocations in a linked list, all other programs on the 
>system only habe 192 allocations available to them."
>       (from _Teach Yourself Win. Programming_ by Charlie Calver)
>
>Oh shit!  My linked list will require way more than 8K pointers.
>What can I do?  Does anyone have any code (or even abstract
>suggestions) about how to deal with the need for 50,000
>pointers in a linked list at one time?

If you have a newer compiler, just use malloc and free.

--
Robert Mashlan             R2M Software Company           Programmer for Hire
mailto:rmashlan@r2m.com    http://www.csn.net/~rmashlan     PGP key available
Resources for Windows Developers    -     http://www.csn.net/~rmashlan/windev
Windows Developers FAQ    -    http://www.csn.net/~rmashlan/win-developer-FAQ

<HR>

> Oh shit!  My linked list will require way more than 8K pointers.
> What can I do?  Does anyone have any code (or even abstract
> suggestions) about how to deal with the need for 50,000
> pointers in a linked list at one time?
>

You can forget about this problem. Just use malloc and free as you
would do this on any other system. Your arguments have been true in
the past, but are no longer true. Every compiler vendor now handles
the process of memory management in windows, overcoming the 8192
handle limit.

Karl Buchegger
## CrossPoint v3.02 ##
<HR>
In article <3s3q9b$h55@solaria.cc.gatech.edu> chrisr@cc.gatech.edu (Christopher D. Reynolds) writes:
>Mike Goelzer (mgoelzer@us.net) wrote:
>: Oh shit!  My linked list will require way more than 8K pointers.
>: What can I do?  Does anyone have any code (or even abstract
>: suggestions) about how to deal with the need for 50,000
>: pointers in a linked list at one time?
>
>You might not like my suggestion, but we have had to do something
>like this in the past. We (actually my boss) wrote a memory manager
>that used GlobalAlloc to get a large chunk of memory and then
>would sub-allocate the memory as needed.
>
>AFAIK This is the only way to do what you want.

        This suballocation scheme is built-in to malloc/new in all (most?)
        compilers today.  Perhaps it wasn't available a year or 2 ago.
-- 
John A. Grant                                           jagrant@emr1.emr.ca
Airborne Geophysics
Geological Survey of Canada, Ottawa
<HR>
malloc() takes an unsigned as an argument so can only do up to
64K-1 bytes.  Use farmalloc() and declare the pointer to which 
you are assigning its return value as _huge

  Ed
  
</PRE>


<HR><A NAME=WINAPI_MEMORY_MEM_RES>
Return to <a href="wpw_wapi_index.html#TOC">Table of Contents for this chapter</a><br>
<H4>Subject: Freeing String/Dialog res memory</H4><PRE>
jvogel@math.rutgers.edu (jeff vogel) wrote:
>My new shareware program is in beta, and the game is crashing - running
>out of memory. I travelled through memory with a utility, and found
>that, strangely, every string resource and dialog that get loaded are
>staying in memory. I can't free them explicityly, because all of the
>involved functions are supposed to delete the things automatically. Or
>so I thought.
>
>What would cause something like this? Are these strings and dialogs cleared
>out automatically when memory gets tight, or is something insidious
>happening? This could be a real problem, as my program uses a LOT of

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -