• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Photoshop allocation behavior

New Here ,
Dec 19, 2008 Dec 19, 2008

Copy link to clipboard

Copied

I'm writing a filter plugin that needs to process extremely large images. We're tiling the image, but due to the nature of our processing we need the tiles to be as big as possible. Therefore, we're allocating several very large buffers, processing a tile, freeing the buffers, and then reallocating them for the next tile. We're using the Buffer suite to do these allocations.

The problem is, the Buffer suite's Dispose function doesn't always seem to actually dispose of the buffer, at least not right away. Using the Buffer suite's GetSpace function as a metric, I see that many of my deallocations don't actually increase the space I have available. Thus, I quickly run out of memory.

Does anybody know anything about this behavior? Is there some sort of garbage-collection thread running? If so, is there some way I can poke it and get it to do its thing and reclaim the memory synchronously? I've tried just sleeping my thread for 10 seconds, and that didn't make any difference. Should I be using the Handle suite instead? My understanding was that that suite is sort of deprecated, and exists primarily for backward compatibility with the old Mac handle allocation functions.

Thanks for any help!

Aaron
TOPICS
SDK

Views

859

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Participant ,
Dec 22, 2008 Dec 22, 2008

Copy link to clipboard

Copied

You could take a large block from Photoshop (e.g. some fraction of its maxSpace estimate) and then allocate and free using your own methods within that block.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 19, 2009 Jan 19, 2009

Copy link to clipboard

Copied

For what it's worth, I purchased a tech support incident from Adobe to ask this question. Specifically, I asked about the failure-to-deallocate issue, and also whether there was any way to deterministically predict how much memory I'd actually be able to get, instead of just guessing based on the total free memory in the heap.

Their response (complete with typos): "Without knowing more about the specifics of your plug-in it's difficult to be certain about the cause of the behabiour you occasionally see after deallocating memory. It could be related to a bug that is currently being worked on.

About the scond question, unfortunately there is no way of getting
Photoshop to return the size of the largest contiguous block of memory."

Not very useful.

Aaron

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 13, 2009 Feb 13, 2009

Copy link to clipboard

Copied

On Mon, 19 Jan 2009 06:37:47 -0800, Aaron_Sher@adobeforums.com wrote:

Not knowing the details, and being in a speculative frame of mind at the
moment, here goes.

Photoshop does tend to hold on to memory, even after images are closed. I
imagine that allocated memory tiles are not associated with a specific
image, but rather to a pool of tiles that are shared among open, or
potentially open images.

Since tiles have a relatively fine granularity, compared to open blocks,
the developers of Photoshop (feel free to chime in here, Chris) did not see
much leverage in fragmenting memory space by deallocating individual tiles,
or moving tiles around, once allocated. Larger blocks of unused tiles will
be swapped out by system VM in any case.

> About the scond question, unfortunately there is no way of getting
> Photoshop to return the size of the largest contiguous block of memory."

In Windows, and probably Mac as well, you can use system calls to march
through the process's allocated memory space.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jan 19, 2009 Jan 19, 2009

Copy link to clipboard

Copied

You do get maxSpace, which is defined as (IIRC) the largest amount that Photoshop is able to free up. You could try allocating half of that, as a rule of thumb, as a single block, then (as I previously suggested) doing intra-block allocation yourself.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Feb 13, 2009 Feb 13, 2009

Copy link to clipboard

Copied

LATEST
tiles are also shared with temporary buffers, presets, compositing intermediate results, etc.

We do dealllocate individual tiles - but that frequently just leads to address space fragmentation (thankfully less so with 64 bit addressing). But yes, we prefer to deallocate large blocks of tiles so that we free up more contiguous space. A plugin can tell Photoshop to free up every tile not currently in use -- and still not have too much contiguous space in 32 bit (because of fragmentation, OS buffers, binaries, etc.)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines