Macaulay2 / Macaulay2/M2

minimize use of new and delete in engine

Open
#983 1 comment 0 reactions 1 assignee View on GitHub

@mikestillman is already working on this.

Since Aug 9, 2019.

Engine
Dominant language
Macaulay2
Stars
435
Forks
297
Avg merge
4d 20h
Merged PRs (30d)
11

Description

In the file e/newdelete.cpp, we redefine global new, delete, to call GC_MALLOC_UNCOLLECTABLE. Removing these definitions causes M2 to crash during startup (reading the m2 files). Changing these calls to GC_MALLOC_ATOMIC also causes M2 to crash.

The main problem is that one cannot have containers containing pointers to GC allocated memory, in a memory block not allocated by GC. (GC == libgc, the Boehm-Demers garbage collector that we use).

But allocating with either the built in new or GC_MALLOC_ATOMIC is faster that GC_MALLOC_UNCOLLECTABLE in inner loop code.

So: change all uses of new in engine code to something like new_atomic, new_container_containing_gc_allocated_memory.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.