473,378 Members | 1,110 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Memory allocation failure

Hello all,

I am writing a Photoshop plug-in on Windows, and I am having trouble
with allocating memory. Essentially, the code performs a very complex
operation on the image, so 9 buffer planes are required as scratch
memory. The problem occurs when the image that a user tries to process
is big, say 10 mega pixels or more. A Photoshop error pops up saying
"Could not complete the command because of a program error".

The error occurs in Photoshop's memory allocation routine,
'FilterRecord->bufferProcs->allocateProc'. It simply fails, hence the
problem must be allocating the memory. So I tried to replace this with
a call to a good old malloc, but trying to allocate the 9 planes
fails, because malloc returns a NULL pointer.

Now the weird thing is that processing a single 10MB will fail,
whereas I can process seven or eight 8MB images without a complaint
from Photoshop. Furthermore, with those seven or eight 8MB still open
in Photoshop, I can process a 20MB image with a command-line
equivalent of the plug-in. So in a nutshell, there is enough memory
as I can allocated twice more memory than what fails in Photoshop, so
what is going on? I could maybe understand that the Photoshop function
refuses to allocate such memory for some reasons, but why does the
malloc in the plug-in fail?! Especially since the malloc in the
command-line equivalent succeeds without a problem for an image TWICE
bigger?!

I would greatly appreciate any comments/ideas/suggestions.

Thanks in advance

Alex

May 22 '07 #1
1 3978
On 22 May 2007 01:49:08 -0700, vectorizor <ve********@googlemail.com>
wrote:
>Hello all,
snip Photoshop discussion
>
Now the weird thing is that processing a single 10MB will fail,
whereas I can process seven or eight 8MB images without a complaint
from Photoshop. Furthermore, with those seven or eight 8MB still open
The fact that "small" allocations succeed while a "large" fails may
indicate nothing more sinister that memory fragmentation. (How many
pieces of kindling will fit through your front door vs how many full
grown redwoods?)
>in Photoshop, I can process a 20MB image with a command-line
equivalent of the plug-in. So in a nutshell, there is enough memory
as I can allocated twice more memory than what fails in Photoshop, so
what is going on? I could maybe understand that the Photoshop function
This would seem to indicate that when Photoshop is active it does
something "strange" to the virtual memory in that task. As with most
virtual memory systems, each task has its own memory and whatever
Photoshop did with its is not affecting your command line task.
>refuses to allocate such memory for some reasons, but why does the
malloc in the plug-in fail?! Especially since the malloc in the
command-line equivalent succeeds without a problem for an image TWICE
bigger?!

I would greatly appreciate any comments/ideas/suggestions.
You really need to discuss this in a Photoshop newsgroup. You have
demonstrated that the problem is not likely in your C code or the C
run time library. Does Adobe provide any kind of tech support?

An alternative design, obviously slower but available immediately, is
to use files instead of allocated memory.
Remove del for email
May 22 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Koen | last post by:
Hi! What is the method you use to handle memory allocation failure in C++ using the "new" operator? I used to only check if a NULL pointer is returned after the "new" call, but that's probably...
4
by: kk | last post by:
Hi all, i didn't get output in the following code while compiling and executing with g++ version 3.2.3 it doesn't allocate memory to pointer varaible (x) in class B. and it gives correct output...
16
by: Jacob | last post by:
It is common practice (I've heard) to always catch allocation exceptions from "new". How is done in practice? What would be a common procedure (path of sequence) after such an event has occured?...
4
by: PaulR | last post by:
Hi, We have a Server running SLES 8 and 3GB memory, with 1 DB2 instance and 2 active Databases. General info... DB2level = "DB2 v8.1.0.72", "s040914", "MI00086", and FixPak "7" uname -a =...
3
by: Hassan Iqbal | last post by:
Hi, (1)if i do the memory allocation like: int **p; p= malloc(n*sizeof p); for(i=0;i<n;i++) /* i and n are integers */ p= malloc(n*sizeof p); then in that case is this command sufficient to...
8
by: clsmyth | last post by:
Folks, Hi, I have never posted to a language group before so please excuse me if this is inappropriate. I have posted this to comp.unix.solaris (well, I am one of the folks on the thread at...
66
by: Johan Tibell | last post by:
I've written a piece of code that uses sockets a lot (I know that sockets aren't portable C, this is not a question about sockets per se). Much of my code ended up looking like this: if...
17
by: dtschoepe | last post by:
Hi, I have a homework project I am working on, so be forwarned, I'm new to C programming. But anyway, having some trouble with a memory allocation issue related to a char * that is a variable...
0
by: kumar | last post by:
HI, I am constantly getting below error. I search on internet but didn't get any help, I would really appreciate if anyone can help me in resolving this issue. I am using DB2 V9.1 and OS is...
10
by: swornavidhya.mahadevan | last post by:
Which allocation (Static / Dynamic) is suitable for the situation when we are trying to allocate for a overloaded memory when the memory is full and no space to allocate. What will happen if both...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.