Re: About HeapCreate()
- From: "mike" <nospamplease>
- Date: Sat, 23 Dec 2006 15:18:04 -0500
Thanks for the input. Can you recommend any articles that discuss a good way
to store data? I mainly want to represent color for each character. I have
thought about CRichEditCtrl but my displayed output needs a border on the
left side. I don't know of a good way to do that with CRichEditCtrl. I am
trying to create a window similar to MFC compile edit window. Spy indicates
that the MFC window is custom.
Thanks
"Joseph M. Newcomer" <newcomer@xxxxxxxxxxxx> wrote in message
news:j56po21qpvrhseiu4d20vt4bs5orsmj5bs@xxxxxxxxxx
Probably a bad idea. Why would you want to use HeapCreate instead of new?
As far as I
know, there is no limit on new, which is also limited by the system
memory.
Consider seriously if a linked list is the right way to handle this. It
almost certainly
is not. Size and speed will be killers. The performance will almost
certainly be a
complete disaster. You will have a tendency to have massive page faults
after a while,
and you can expect performance degradation by orders of magnitude (like 3
to 6 orders of
magnitude). I would seriously consider re-evaluating any decision to
represent one
character per list cell. Run-coded compression (sequences of text) would
be better,
particularly for very large documents (think RTF-style or html-style
representations in
the encoding). Another representation is massive chunks of data with the
formatting
represented as metadata. They are more complex to maintain, but consider:
each character
is going to consume a *minimum* of 16 bytes of memory (8 bytes of overhead
and 8 bytes of
allocation), not counting whatever formatting information you want to
store with it, so
you immediately start losing orders of magnitude of space. Orders of
magnitude of space
translate into orders of magnitude performance.
Size of code never matters; anyone who worries about code size in Windows
is worrying
about an irrelevant problem. But *data* size will kill you. You have
chosen a
representation that is massively profligate of data size. Consider that
although the
address space is flat, paging is your worst enemy, and you have chosen a
representation
that is guaranteed to maximize paging activity.
L1 cache hits cost 0 CPU cycles to get the data. L2 cache hits cost 1 or
2 CPU cycles to
get the data. L2 cache misses cost 20 CPU cycles. A page fault costs
20,000,000 CPU
cycles. This is why linked lists of one character per list cell in this
context are about
the worst possible representation of information you can design, because
they are
guaranteed to maximize page faults. Don't believe that data access is
uniform.
joe
On Fri, 22 Dec 2006 17:43:03 -0500, "mike" <nospamplease> wrote:
I have created a custom edit view from CView which uses a linked list forJoseph M. Newcomer [MVP]
character cells. I am using the Heap functions (HeapCreate(),
HeapAlloc()...etc) to allocate cells. This all seems to work ok and now I
am
going to create an undo buffer. This buffer will use the same Heap since
the
current view cells will be copied and saved in the undo buffer and will
need
to be deleted when the view is deleted. The documentation says that the
Heap
functions are only limited by system memory. Since I want to handle large
documents, I was wondering if I am ok using this method or if someone
could
enlighten me on a better memory method.
thanks
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.
- Follow-Ups:
- Re: About HeapCreate()
- From: marcoera
- Re: About HeapCreate()
- From: Joseph M . Newcomer
- Re: About HeapCreate()
- References:
- About HeapCreate()
- From: mike
- Re: About HeapCreate()
- From: Joseph M . Newcomer
- About HeapCreate()
- Prev by Date: Re: Has COleDatabase changed since VC6 ??
- Next by Date: Where do I ask questions about using Microsoft Visual C++ 2005 Express Edition?
- Previous by thread: Re: About HeapCreate()
- Next by thread: Re: About HeapCreate()
- Index(es):
Relevant Pages
|