Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GCD and rpmalloc_thread_initialize #73

Closed
vitorhugomagalhaes opened this issue Jun 27, 2018 · 11 comments
Closed

GCD and rpmalloc_thread_initialize #73

vitorhugomagalhaes opened this issue Jun 27, 2018 · 11 comments
Assignees

Comments

@vitorhugomagalhaes
Copy link

Hi,

I'm trying to include rpmalloc into my ios project however, since we use GCD I'm not sure where to call rpmalloc_thread_initialize.

Without this call the app crashes in all the callers that are not performed in the main thread where rpmalloc_initialize was called.

Thanksm

@mjansson
Copy link
Owner

Are you using the malloc wrappers in malloc.c? The idea is that the pthread create calls should be intercepted and threads automagically initialized.

@vitorhugomagalhaes
Copy link
Author

I tried the malloc wrappers and the code crashes. I'm not sure that intercepting the pthread_create actually solves the issue when using GCD. Are you sure GCD threads are created with pthread library ?

@mjansson
Copy link
Owner

Can you share a minimal reproduction case for this?

@mjansson mjansson self-assigned this Jul 22, 2018
@victorstewart
Copy link

victorstewart commented Nov 9, 2018

hey I also was really interested in using rpmalloc in my iOS app (Objective C++), but I also use GCD to dispatch work at will... thus can't (if the malloc wrappers are insufficient as described above). I use a lot of static queues to synchronize memory access... but all object creation happens on random queues aka dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0).

I haven't tested any of this though, just exploring the idea right now.

Theoretically I could and would use known/static queues to do all allocations on, if that's necessary to use rpmalloc.. once the more general problem of "will it work with GCD" is sorted out.

@dcouture2
Copy link

You could try it out with this branch

https://github.com/dcou/rpmalloc-greedy/tree/greedy_unmap

@victorstewart
Copy link

@dcouture2 what’s the difference? i don’t see it in the readme

@dcou
Copy link

dcou commented Nov 12, 2018

@mjansson
Copy link
Owner

Related #63

@mjansson
Copy link
Owner

mjansson commented Apr 4, 2019

Any chance you could provide a minimal reproduction of this issue?

@mjansson
Copy link
Owner

Ping @vitorhugomagalhaes and @victorstewart on providing more info or a reproduction case

@mjansson
Copy link
Owner

This should work now in latest develop branch if ENABLE_PRELOAD is set to 1 (in which case each thread will self-init when needed)

@mjansson mjansson closed this as completed Aug 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants