# Allocation related problems

Hi, I have a question when I call python bayesian optimization from julia, but my problem is not about bayesian optimization, I think it should be related to memory allocation problems, here is an example that can show the structure of my real program, but cannot show my problem because it’s too simple. In my real program, the function `fx` includes some variables defined according to the x,y (in reality, not only two parameters but about 10 parameters) values, and it includes a ODEs which means it will occupy some memory.
My problem is since I use pmap, and it can solve very quickly once a new group of `(x,y)` is passed to `fx` but then it will need about 15 minutes(during this time, the cpu occupation rate is about 20%, while it’s calculating, cpu rate is 100%) to wait for another group `(x,y)` to calculate. Maybe it’s just try to find the suitable next `(x,y)`, I am just wondering whether it’s because everytime it finishs running, it needs to clear the memory and that takes lots of time, thanks, it’s very hard to express my problem clearly. Any suggestions are welcome

``````@everywhere function fx(a, x, y)
return -x^a - (y - 1)^a
end

function black_box_function(; x, y)
F = pmap(a -> fx(a, x, y), itm)
return sum(F)
end

@everywhere using PyCall, Distributed, LinearAlgebra
@everywhere begin
const itm = 1:10
end

py"""
pbounds = {'x': (2, 4), 'y': (-3, 3)}
"""
temp = pyimport("bayes_opt")

optimizer = temp.BayesianOptimization(
f = black_box_function,
pbounds = py"pbounds",
random_state = 1,
)

optimizer.maximize(
init_points = 2,
n_iter = 3,
)

print(optimizer.max)
``````