Opened 16 years ago

Closed 16 years ago

#560 closed enhancement (fixed)

Optimize the memory usage of DNS resolver

Reported by: bennylp Owned by: bennylp
Priority: normal Milestone: release-1.0-rc1
Component: pjlib-util Version: trunk
Keywords: Cc:
Backport to 1.x milestone: Backported:

Description (last modified by bennylp)

Previously, the DNS resolver (resolver.c) allocates memory for caching DNS answers from the resolver pool, and stores the unused entries in free list. This would cause memory to grow as much as the total number of unique names resolved, and this memory will not be released until the resolver is destroyed.

With the new approach, each DNS answer cache entry will have it's own pool, and when the answer/entry expires, the pool will be destroyed, thus releasing the memory back to the OS.

Also change the pool type used to store the entry. Previously entry uses a fixed size buffer to allocate the memory from, using fixed buffer pool (pool_buf.h. Because of this, entry is created with buffer that must be large enough to parse DNS answer, and if the answer is larger than the buffer size, parsing will fail.

This limitation will be gone when we change the pool type to use normal pool instead.

Change History (1)

comment:1 Changed 16 years ago by bennylp

  • Description modified (diff)
  • Resolution set to fixed
  • Status changed from new to closed

Done in r2124:

  • use one pool for each entry
  • replace fixed memory pool with normal pool
  • reduce default cache size from 1000 down to 512 bytes
Note: See TracTickets for help on using tickets.