# JuceVSTWrapper calling malloc

**URL:** <https://forum.juce.com/t/jucevstwrapper-calling-malloc/43062>\
**Category:** General JUCE discussion\
**Created:** [December 3, 2020, 9:55am UTC](https://forum.juce.com/t/jucevstwrapper-calling-malloc/43062 "2020-12-03T09:55:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![domenicostefani](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/domenicostefani/32/8251_2.png) [@domenicostefani](https://forum.juce.com/u/domenicostefani)\
**Post date:** [December 3, 2020, 9:55am UTC](https://forum.juce.com/t/jucevstwrapper-calling-malloc/43062/1 "2020-12-03T09:55:05Z")

</div>

Hi everyone,  
I’m trying to do a very simple thing: expose a floating point parameter in a vst plugin.  
It seems to me that the first time the parameter is set from outside the plugin, the VST Wrapper allocates memory (Juce 5.4.5, will update probably after Christmas).  
**Is it ok?** Is there a way to “prime” the system so that it preallocates that memory and leaves it there without affecting the real time execution?

I found out about this because I compile my vst for Elk and it allows me to debug mode switches of the rt kernel.  
Here is the gdb backtrace:

```
Thread 10 "sushi_b64" hit Catchpoint 1 (signal SIGXCPU), __GI___ mmap64 (
    offset=<optimized out>, fd=-1, flags=16418, prot=0, len=134217728, 
    addr=<optimized out>) at ../sysdeps/unix/sysv/linux/mmap64.c:52
52	../sysdeps/unix/sysv/linux/mmap64.c: No such file or directory.
(gdb) bt
#0 __GI___ mmap64 (offset=<optimized out>, fd=-1, flags=16418, prot=0, 
    len=134217728, addr=<optimized out>)
    at ../sysdeps/unix/sysv/linux/mmap64.c:52
#1 __GI___ mmap64 (addr=addr@entry=0x0, len=len@entry=134217728, 
    prot=prot@entry=0, flags=flags@entry=16418, fd=fd@entry=-1, 
    offset=offset@entry=0) at ../sysdeps/unix/sysv/linux/mmap64.c:40
#2 0x0000007ff77169c4 in new_heap (size=135168, size@entry=2824, 
    top_pad=<optimized out>) at arena.c:487
#3 0x0000007ff7717548 in _int_new_arena (size=576) at arena.c:911
#4 arena_get2 (avoid_arena=0x0, size=576) at arena.c:911
#5 arena_get2 (size=576, avoid_arena=0x0) at arena.c:872
#6 0x0000007ff7719e2c in tcache_init () at malloc.c:2994
#7 0x0000007ff771abc8 in tcache_init () at malloc.c:3050
#8 __GI___ libc_malloc (bytes=24) at malloc.c:3050
#9 0x0000007ff796f46c in operator new(unsigned long) ()
   from /usr/lib/libstdc++.so.6
#10 0x0000007feeb57540 in juce::ThreadLocalValue<bool>::get (this=0x5555808f88)
    at /opt/elk/1.0/sysroots/aarch64-elk-linux/usr/include/c++/8.3.0/bits/atomic_base.h:707
#11 juce::ThreadLocalValue<bool>::operator= (newValue=<optimized out>, 
    this=0x5555808f88)
    at /home/domenico/elkJUCE/modules/juce_core/threads/juce_ThreadLocalValue.h:88
--Type <RET> for more, q to quit, c to continue without paging--c
#12 JuceVSTWrapper::setParameter (value=0, index=<optimized out>, this=0x5555808b00) at /home/domenico/elkJUCE/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp:795
#13 JuceVSTWrapper::setParameterCB (vstInterface=<optimized out>, index=<optimized out>, value=0) at /home/domenico/elkJUCE/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp:802
#14 0x00000055555b74b4 in ?? ()
#15 0x00000055555b78ec in ?? ()
#16 0x00000055555ab90c in ?? ()
#17 0x0000005555646dc4 in ?? ()
#18 0x0000005555635eec in ?? ()
#19 0x0000007ff7e9c0c8 in ?? () from /usr/xenomai/lib/libcobalt.so.2
#20 0x0000007ff7da5824 in start_thread (arg=0x7ffffff406) at pthread_create.c:486
#21 0x0000007ff77717bc in thread_start () at ../sysdeps/unix/sysv/linux/aarch64/clone.S:78

```

Thanks
