Skip to content

optimization: consider alternative document free mechanisms that will allow setting RUBY_TYPED_FREE_IMMEDIATELY #2822

@flavorjones

Description

@flavorjones

See 0804380 for more context, but essentially:

  • we parent unparented nodes at the last minute so that xmlFreeDoc frees all the underlying memory for us
  • if two text nodes happen to end up siblings during that process, they are merged and libxml2 may allocate additional memory via ruby_xmalloc
  • it may be unsafe to allocate memory during GC, warnings will be raised

Working on #2807 made me realize that we're doing more work during the deallocate function than I thought -- so it's both slower and less safe than it could be.

I have at least one idea, which is instead of parenting the unparented nodes, just call xmlFreeNode on them to avoid the parenting overhead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic/memorySegfaults, memory leaks, valgrind testing, etc.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions