Is there a way to read data from CGImage without internal caching?
up vote
1
down vote
favorite
I am fighting with an internal caching (about 90 MB for 15 mp image ) in CGContextDrawImage
/CGDataProviderCopyData
functions.
Here is the stack-trace in profiler:
In all cases, IOSurface
is created as a "cache", and isn't cleaned after @autoreleasepool
is drained.
This leaves a very few chances for an app to survive.
Caching doesn't depend on image size: I tried to render 512x512
, as well as 4500x512
and 4500x2500
(full-size) image chunks.
I use @autoreleasepool
, CFGetRetainCount
returns 1
for all CG
-objects before cleaning them.
The code which manipulates the data:
+ (void)render11:(CIImage*)ciImage fromRect:(CGRect)roi toBitmap:(unsigned char*)bitmap
@autoreleasepool
int w = CGRectGetWidth(roi), h = CGRectGetHeight(roi);
CIContext* ciContext = [CIContext contextWithOptions:nil];
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef cgContext = CGBitmapContextCreate(bitmap, w, h,
8, w*4, colorSpace,
kCGImageAlphaPremultipliedLast
What I know about IOSurface
: it's from the previously private framework IOSurface
. CIContext
has a function render: ... toIOSurface:
.
I've created my IOSurfaceRef
and passed it to this function, and the internal implementation still creates its own surface, and doesn't clean it.
So, do you know (or assume):
1. Are there other ways to read CGImage's data buffer except
CGContextDrawImage
/CGDataProviderCopyData
?
2. Is there a way to disable caching at render?
3. Why does the caching happen?
4. Can I use some lower-level (while non-private) API to manually clean up system memory?
Any suggestions are welcome.
ios caching core-graphics core-image iosurface
add a comment |
up vote
1
down vote
favorite
I am fighting with an internal caching (about 90 MB for 15 mp image ) in CGContextDrawImage
/CGDataProviderCopyData
functions.
Here is the stack-trace in profiler:
In all cases, IOSurface
is created as a "cache", and isn't cleaned after @autoreleasepool
is drained.
This leaves a very few chances for an app to survive.
Caching doesn't depend on image size: I tried to render 512x512
, as well as 4500x512
and 4500x2500
(full-size) image chunks.
I use @autoreleasepool
, CFGetRetainCount
returns 1
for all CG
-objects before cleaning them.
The code which manipulates the data:
+ (void)render11:(CIImage*)ciImage fromRect:(CGRect)roi toBitmap:(unsigned char*)bitmap
@autoreleasepool
int w = CGRectGetWidth(roi), h = CGRectGetHeight(roi);
CIContext* ciContext = [CIContext contextWithOptions:nil];
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef cgContext = CGBitmapContextCreate(bitmap, w, h,
8, w*4, colorSpace,
kCGImageAlphaPremultipliedLast
What I know about IOSurface
: it's from the previously private framework IOSurface
. CIContext
has a function render: ... toIOSurface:
.
I've created my IOSurfaceRef
and passed it to this function, and the internal implementation still creates its own surface, and doesn't clean it.
So, do you know (or assume):
1. Are there other ways to read CGImage's data buffer except
CGContextDrawImage
/CGDataProviderCopyData
?
2. Is there a way to disable caching at render?
3. Why does the caching happen?
4. Can I use some lower-level (while non-private) API to manually clean up system memory?
Any suggestions are welcome.
ios caching core-graphics core-image iosurface
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I am fighting with an internal caching (about 90 MB for 15 mp image ) in CGContextDrawImage
/CGDataProviderCopyData
functions.
Here is the stack-trace in profiler:
In all cases, IOSurface
is created as a "cache", and isn't cleaned after @autoreleasepool
is drained.
This leaves a very few chances for an app to survive.
Caching doesn't depend on image size: I tried to render 512x512
, as well as 4500x512
and 4500x2500
(full-size) image chunks.
I use @autoreleasepool
, CFGetRetainCount
returns 1
for all CG
-objects before cleaning them.
The code which manipulates the data:
+ (void)render11:(CIImage*)ciImage fromRect:(CGRect)roi toBitmap:(unsigned char*)bitmap
@autoreleasepool
int w = CGRectGetWidth(roi), h = CGRectGetHeight(roi);
CIContext* ciContext = [CIContext contextWithOptions:nil];
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef cgContext = CGBitmapContextCreate(bitmap, w, h,
8, w*4, colorSpace,
kCGImageAlphaPremultipliedLast
What I know about IOSurface
: it's from the previously private framework IOSurface
. CIContext
has a function render: ... toIOSurface:
.
I've created my IOSurfaceRef
and passed it to this function, and the internal implementation still creates its own surface, and doesn't clean it.
So, do you know (or assume):
1. Are there other ways to read CGImage's data buffer except
CGContextDrawImage
/CGDataProviderCopyData
?
2. Is there a way to disable caching at render?
3. Why does the caching happen?
4. Can I use some lower-level (while non-private) API to manually clean up system memory?
Any suggestions are welcome.
ios caching core-graphics core-image iosurface
I am fighting with an internal caching (about 90 MB for 15 mp image ) in CGContextDrawImage
/CGDataProviderCopyData
functions.
Here is the stack-trace in profiler:
In all cases, IOSurface
is created as a "cache", and isn't cleaned after @autoreleasepool
is drained.
This leaves a very few chances for an app to survive.
Caching doesn't depend on image size: I tried to render 512x512
, as well as 4500x512
and 4500x2500
(full-size) image chunks.
I use @autoreleasepool
, CFGetRetainCount
returns 1
for all CG
-objects before cleaning them.
The code which manipulates the data:
+ (void)render11:(CIImage*)ciImage fromRect:(CGRect)roi toBitmap:(unsigned char*)bitmap
@autoreleasepool
int w = CGRectGetWidth(roi), h = CGRectGetHeight(roi);
CIContext* ciContext = [CIContext contextWithOptions:nil];
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef cgContext = CGBitmapContextCreate(bitmap, w, h,
8, w*4, colorSpace,
kCGImageAlphaPremultipliedLast
What I know about IOSurface
: it's from the previously private framework IOSurface
. CIContext
has a function render: ... toIOSurface:
.
I've created my IOSurfaceRef
and passed it to this function, and the internal implementation still creates its own surface, and doesn't clean it.
So, do you know (or assume):
1. Are there other ways to read CGImage's data buffer except
CGContextDrawImage
/CGDataProviderCopyData
?
2. Is there a way to disable caching at render?
3. Why does the caching happen?
4. Can I use some lower-level (while non-private) API to manually clean up system memory?
Any suggestions are welcome.
ios caching core-graphics core-image iosurface
ios caching core-graphics core-image iosurface
asked 2 days ago
Olia_Pavliuk
517519
517519
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
If you just need to manipulate CIImage data, may consider to use CIImageProcessorKernel to put data into CPU or GPU calculation without extracting them.
I notice that
[ciContext
render:image toBitmap:bitmap rowBytes: w*4 bounds:image.extent format:kCIFormatRGBA8 colorSpace:colorSpace];
There is no such 90M cache. Maybe it's what you want.
Thanks! I do need to read the data intounsigned char*
buffer. Is it possible withCIImageProcessorKernel
?
– Olia_Pavliuk
yesterday
It depends on knowledge level. Baseaddress has the data you need. If you cannot get it out, Simply way is to render to somewhere like iosurface or screen then capture screen.
– E.Coms
yesterday
cgimage can render directly to data. If i call createCGImage, it's 260M. call this it's only 170M during peak.
– E.Coms
yesterday
"Baseaddress has the data you need" - thanks, I'll try. "cgimage can render directly to data. If i call createCGImage" - yeah, but CGContextDrawImage does that unwanted caching inside
– Olia_Pavliuk
yesterday
1
"Baseaddress has the data you need." Yes, but you may not get it out of the block.
– E.Coms
yesterday
|
show 4 more comments
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
If you just need to manipulate CIImage data, may consider to use CIImageProcessorKernel to put data into CPU or GPU calculation without extracting them.
I notice that
[ciContext
render:image toBitmap:bitmap rowBytes: w*4 bounds:image.extent format:kCIFormatRGBA8 colorSpace:colorSpace];
There is no such 90M cache. Maybe it's what you want.
Thanks! I do need to read the data intounsigned char*
buffer. Is it possible withCIImageProcessorKernel
?
– Olia_Pavliuk
yesterday
It depends on knowledge level. Baseaddress has the data you need. If you cannot get it out, Simply way is to render to somewhere like iosurface or screen then capture screen.
– E.Coms
yesterday
cgimage can render directly to data. If i call createCGImage, it's 260M. call this it's only 170M during peak.
– E.Coms
yesterday
"Baseaddress has the data you need" - thanks, I'll try. "cgimage can render directly to data. If i call createCGImage" - yeah, but CGContextDrawImage does that unwanted caching inside
– Olia_Pavliuk
yesterday
1
"Baseaddress has the data you need." Yes, but you may not get it out of the block.
– E.Coms
yesterday
|
show 4 more comments
up vote
1
down vote
If you just need to manipulate CIImage data, may consider to use CIImageProcessorKernel to put data into CPU or GPU calculation without extracting them.
I notice that
[ciContext
render:image toBitmap:bitmap rowBytes: w*4 bounds:image.extent format:kCIFormatRGBA8 colorSpace:colorSpace];
There is no such 90M cache. Maybe it's what you want.
Thanks! I do need to read the data intounsigned char*
buffer. Is it possible withCIImageProcessorKernel
?
– Olia_Pavliuk
yesterday
It depends on knowledge level. Baseaddress has the data you need. If you cannot get it out, Simply way is to render to somewhere like iosurface or screen then capture screen.
– E.Coms
yesterday
cgimage can render directly to data. If i call createCGImage, it's 260M. call this it's only 170M during peak.
– E.Coms
yesterday
"Baseaddress has the data you need" - thanks, I'll try. "cgimage can render directly to data. If i call createCGImage" - yeah, but CGContextDrawImage does that unwanted caching inside
– Olia_Pavliuk
yesterday
1
"Baseaddress has the data you need." Yes, but you may not get it out of the block.
– E.Coms
yesterday
|
show 4 more comments
up vote
1
down vote
up vote
1
down vote
If you just need to manipulate CIImage data, may consider to use CIImageProcessorKernel to put data into CPU or GPU calculation without extracting them.
I notice that
[ciContext
render:image toBitmap:bitmap rowBytes: w*4 bounds:image.extent format:kCIFormatRGBA8 colorSpace:colorSpace];
There is no such 90M cache. Maybe it's what you want.
If you just need to manipulate CIImage data, may consider to use CIImageProcessorKernel to put data into CPU or GPU calculation without extracting them.
I notice that
[ciContext
render:image toBitmap:bitmap rowBytes: w*4 bounds:image.extent format:kCIFormatRGBA8 colorSpace:colorSpace];
There is no such 90M cache. Maybe it's what you want.
edited yesterday
answered 2 days ago
E.Coms
1,1161410
1,1161410
Thanks! I do need to read the data intounsigned char*
buffer. Is it possible withCIImageProcessorKernel
?
– Olia_Pavliuk
yesterday
It depends on knowledge level. Baseaddress has the data you need. If you cannot get it out, Simply way is to render to somewhere like iosurface or screen then capture screen.
– E.Coms
yesterday
cgimage can render directly to data. If i call createCGImage, it's 260M. call this it's only 170M during peak.
– E.Coms
yesterday
"Baseaddress has the data you need" - thanks, I'll try. "cgimage can render directly to data. If i call createCGImage" - yeah, but CGContextDrawImage does that unwanted caching inside
– Olia_Pavliuk
yesterday
1
"Baseaddress has the data you need." Yes, but you may not get it out of the block.
– E.Coms
yesterday
|
show 4 more comments
Thanks! I do need to read the data intounsigned char*
buffer. Is it possible withCIImageProcessorKernel
?
– Olia_Pavliuk
yesterday
It depends on knowledge level. Baseaddress has the data you need. If you cannot get it out, Simply way is to render to somewhere like iosurface or screen then capture screen.
– E.Coms
yesterday
cgimage can render directly to data. If i call createCGImage, it's 260M. call this it's only 170M during peak.
– E.Coms
yesterday
"Baseaddress has the data you need" - thanks, I'll try. "cgimage can render directly to data. If i call createCGImage" - yeah, but CGContextDrawImage does that unwanted caching inside
– Olia_Pavliuk
yesterday
1
"Baseaddress has the data you need." Yes, but you may not get it out of the block.
– E.Coms
yesterday
Thanks! I do need to read the data into
unsigned char*
buffer. Is it possible with CIImageProcessorKernel
?– Olia_Pavliuk
yesterday
Thanks! I do need to read the data into
unsigned char*
buffer. Is it possible with CIImageProcessorKernel
?– Olia_Pavliuk
yesterday
It depends on knowledge level. Baseaddress has the data you need. If you cannot get it out, Simply way is to render to somewhere like iosurface or screen then capture screen.
– E.Coms
yesterday
It depends on knowledge level. Baseaddress has the data you need. If you cannot get it out, Simply way is to render to somewhere like iosurface or screen then capture screen.
– E.Coms
yesterday
cgimage can render directly to data. If i call createCGImage, it's 260M. call this it's only 170M during peak.
– E.Coms
yesterday
cgimage can render directly to data. If i call createCGImage, it's 260M. call this it's only 170M during peak.
– E.Coms
yesterday
"Baseaddress has the data you need" - thanks, I'll try. "cgimage can render directly to data. If i call createCGImage" - yeah, but CGContextDrawImage does that unwanted caching inside
– Olia_Pavliuk
yesterday
"Baseaddress has the data you need" - thanks, I'll try. "cgimage can render directly to data. If i call createCGImage" - yeah, but CGContextDrawImage does that unwanted caching inside
– Olia_Pavliuk
yesterday
1
1
"Baseaddress has the data you need." Yes, but you may not get it out of the block.
– E.Coms
yesterday
"Baseaddress has the data you need." Yes, but you may not get it out of the block.
– E.Coms
yesterday
|
show 4 more comments
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53225002%2fis-there-a-way-to-read-data-from-cgimage-without-internal-caching%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password