# What is a custom mark function supposed to return?

**URL:** https://discourse.julialang.org/t/what-is-a-custom-mark-function-supposed-to-return/87877
**Category:** General Usage
**Tags:** garbage-collection, c
**Created:** [September 27, 2022, 5:12pm UTC](https://discourse.julialang.org/t/what-is-a-custom-mark-function-supposed-to-return/87877 "2022-09-27T17:12:29Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Taaitaaiger](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/taaitaaiger/32/49792_2.png) [@Taaitaaiger](https://discourse.julialang.org/u/Taaitaaiger)
#### Post date: [September 27, 2022, 5:12pm UTC](https://discourse.julialang.org/t/what-is-a-custom-mark-function-supposed-to-return/87877/1 "2022-09-27T17:12:29Z")

</div>

You can create foreign types that have custom mark and sweep functions with `jl_new_foreign_type`. The custom mark function must return a `uintptr_t`, but it’s undocumented what should be returned exactly.

The custom mark is called [here](https://github.com/JuliaLang/julia/blob/master/src/gc.c#L2835), my assumption is that either it needs to return 1 if the instance of the foreign type contains at least one pointer to a young object, or that it needs to return the number of pointers to young objects, but I’m not sure.

---

<div class="post-metadata">

### Author: ![Taaitaaiger](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/taaitaaiger/32/49792_2.png) [@Taaitaaiger](https://discourse.julialang.org/u/Taaitaaiger)
#### Post date: [October 26, 2022, 2:44pm UTC](https://discourse.julialang.org/t/what-is-a-custom-mark-function-supposed-to-return/87877/2 "2022-10-26T14:44:33Z")

</div>

In case anyone else is curious, I figured out it’s the number of pointers to young objects based on this test: [julia/gcext.c at 7cbf55f4677d243629e685348726ab4941a50706 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/blob/7cbf55f4677d243629e685348726ab4941a50706/test/gcext/gcext.c#L541)
