Skip to main content
marks81797503
Known Participant
September 4, 2026
Question

PF_PreRenderOutput::pre_render_data — who frees it, and when? (SDK example doesn't show it)

  • September 4, 2026
  • 1 reply
  • 24 views

Dear Adobe Teams,

Working through the After Effects SDK's (2019) Smart Render pattern, and the sample code leaves the ownership/lifetime of pre_render_data genuinely ambiguous.

In PF_Cmd_SMART_PRE_RENDER (SDK/Examples/Effect/R_O_I/R_O_I.cpp, ~line 201):

cpp
extra->output->pre_render_data = new ROI_RenderInfo();

ROI_RenderInfo infoP = reinterpret_cast<ROI_RenderInfo>(extra->output->pre_render_data);

if (!infoP) {
    err = PF_Err_OUT_OF_MEMORY;
} else {
    // ...infoP fields get filled in here...
}

Then in PF_Cmd_SMART_RENDER (~line 392), the same data comes back through extra->input:

cpp
info.we_care_about_alphaB = (static_cast<A_Boolean>(extra->input->pre_render_data));

That's the entire lifecycle shown in the sample. I checked the whole file for delete, free, or any assignment to output->delete_pre_render_data_func — there is none. The struct allocated with new in PreRender is read once in SmartRender and then never explicitly disposed anywhere in this 400+ line file.

Questions:

Since this sample never sets delete_pre_render_data_func, is AE expected to free pre_render_data on its own using some default mechanism (e.g. treating it as a simple heap block), or does this sample simply leak it?
If a plugin does set delete_pre_render_data_func, is AE responsible for calling it after SmartRender finishes with that data — and is that guaranteed to happen exactly once, even across multiple SmartRender calls against one PreRender result (e.g. multi-frame/multi-view renders)?
If the plugin is instead expected to free pre_render_data itself inside SmartRender, should R_O_I.cpp be treated as a known gap in the sample rather than the recommended pattern?

A short confirmation of which side owns the free — and whether this sample simply omits it — would clear this up. Thanks.

    1 reply

    Community Expert
    September 4, 2026

    Hi Marks.
    I don’t know the answer to all the questions you asked here, but here’s what i do know:
    1. back in CC2015, the delete_pre_render_data_func callback was broken and never called. it was fixed a few versions later when a dev reported it. that is to say, i think most devs don’t use the pre_render_data handle at all…
    2. ideally, any pre-render call that stores pre_render_data and passes a delete_pre_render_data_func, should get exatly one delete_pre_render_data_func call for each pre-render call.
    3. if i recall correctly, when not passing a delete_pre_render_data_func, AE would delete expired pre_render_data by itself.
    4. here’s what i’m not sure about: should you delete pre_render_data manually upon usage? i’m not sure… if you get regular delete_pre_render_data_func calls, then perhaps it’s best to leave it to that. you can do a test and store specific data in each pre_render calls, and then see of you get a delete_pre_render_data_func with the specific data you got on the single render call.