Re: About HeapCreate()

Tech-Archive recommends: Fix windows errors by optimizing your registry



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 for
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

Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm


.



Relevant Pages

  • Re: About HeapCreate()
    ... and you can expect performance degradation by orders of magnitude (like 3 to 6 orders of ... Another representation is massive chunks of data with the formatting ... They are more complex to maintain, but consider: each character ... HeapAlloc...etc) to allocate cells. ...
    (microsoft.public.vc.mfc)
  • Re: find and replace Excel 2007
    ... My other guess is that you have something in those cells. ... number keypad) to enter the character into the Other box in the text to columns ... Dim iCtr As Long ... Debra Dalgleish has some notes how to implement macros here: ...
    (microsoft.public.excel.worksheet.functions)
  • Re: diferences between 22 and python 23
    ... string objects have the same byte ... >representation that they originally had in the source code. ... Then they must have encoding info attached? ... behind the concrete character representations there are abstract entities ...
    (comp.lang.python)
  • Re: Reading "normal" text files with Wide_Text_IO in GNAT
    ... I'd still like to know where UCS-1 is defined, ... character, then that character is represented simply by a 2- or 4-byte ... binary representation of N ... In fact UCS-2 and UCS-4 are specific names for Unicode stuff. ...
    (comp.lang.ada)
  • Re: Quest-ce que cest "--()"?
    ... "Dave R." ... > and want to count the number of these entries with 3 as the 3rd character, ... > to count the number of times '5' is the value of the cells in A1:A100. ... >>>> check them against the criteria. ...
    (microsoft.public.excel.worksheet.functions)