When using (ngx_parse_url(ngx_cycle->pool, &u) != NGX_OK) to parse URLs, if the domain name changes very frequently, the memory occupied by ngx_cycle->pool will increase continually. This memory is only released when Nginx is reloaded. Creating a new memory pool can solve this issue.
There is a memory leak in dynamic_server[i].previous_pool which needs to be checked if it is null. During the first assignment, dynamic_server->previous_pool = dynamic_server->pool, dynamic_server->pool is null. In the second assignment, it is assigned a new value (new_pool), hence the memory allocated for the previous new_pool is not released.