Re: Symbol table



rhyde@xxxxxxxxxx wrote:
T.M. Sommers wrote:

This seems to me to be a premature optimization. It should only
be tried if you have proven that malloc()ing symbols individually
is a real bottleneck.

Or after looking at the space overhead required for a malloc operation.
Don't forget that most memory managers reserve something like 8 to 16
bytes of metadata to keep track of the allocation. If you allocate
1000s of 20-byte objects via malloc, you could wind up using twice as
much space.

Of course, on modern machines, who really cares. Even if you allocate
1,000,000 symbols, that's only 20MB, not much on a 2GB machine :-)

The OP's method will have its overhead, too. Espeically if you ever want to free any symbols, such as when they go out of scope. If you don't free such symbols, that is another kind of overhead.

--
Thomas M. Sommers -- tms@xxxxxx -- AB2SB


.



Relevant Pages

  • Re: Recursive subroutine for reading null-terminated string
    ... and any other call overhead. ... I thought that normal arrays are allocated a single ... and just before the ALLOCATE. ... for recursion up to that point. ...
    (comp.lang.fortran)
  • Re: State of Forth 200x
    ... run-time overhead ... It's just ALLOCATE and MOVE to copy a small memory region, ... dumb old W32F) in using them. ... IMO objects that are definitely needed ...
    (comp.lang.forth)
  • Re: page sizes
    ... The documentation of malloc() on one of the ... Larger blocks allocate fastest if they are ... overhead by always putting chunks on cacheline boundaries (and wasting ...
    (comp.programming)
  • Re[2]: [PATCH][v2] fork_init: fix division by zero
    ... overhead before this patch: e.g. your implementation is finally boils ... common situation of small PAGE_SIZEs. ... can't allocate thread structs from highmem. ... Emcraft Systems, www.emcraft.com ...
    (Linux-Kernel)
  • Re: missing madvise functionality
    ... mmap/mprotect, which have more fundamental locking requirements, more ... overhead and no benefits (except debugging, ... So far, when we allocate a new arena, we allocate address space with ...
    (Linux-Kernel)