caching - imageWithCGImage not being released or is trapped by Cache similar to imageNamed, any work around for generating dynamic images? -
caching - imageWithCGImage not being released or is trapped by Cache similar to imageNamed, any work around for generating dynamic images? -
i'm generating uiimages bit-bucket, creating them on fly , swapping uiimageview's image. there way edit uiimageview's image directly? (ie. alter color of specific pixel, without removing uiimage uiimageview, , redraw.)
currently, i'm flushing uiimage , using imagewithcgiimage create new one, , assigning uiimageview. works. shows no memleaks. on iphone (3gs) after 100 image replacements, crashes. cache'n issue? memory addition seems hitting phone's limit if cache not releasing, however, simulator not show memory consumption each image swap. stays flatlined without leaks.
note: topologyimage array rgba pixel-bucket. ref variables not released. every effort so, crashes next call. without, instruments reports no leaks.
=========
cgcolorspaceref colorspaceref=cgcolorspacecreatedevicergb(); cgbitmapinfo bitmapinfo = kcgbitmapbyteorderdefault | kcgimagealphalast; cgcolorrenderingintent renderingintent=kcgrenderingintentdefault; cgdataproviderref provider=cgdataprovidercreatewithdata(null,topologyimage,(i*i*4),null); cgimageref imageref=cgimagecreate(i,i,8,4*8,4*i,colorspaceref,bitmapinfo,provider,null,false,renderingintent); uiimage *img=[uiimage imagewithcgimage:imageref]; if( img[ndxtopo].vw ) { [img[ndxtopo].vw setimage:img]; } else { img[ndxtopo].vw=[[uiimageview alloc] initwithimage:img]; [master.view addsubview:img[ndxtopo].vw]; }
basically should release references, cgimageref since imagewithcgimage doesn't take ownership of cgimage rather seems re-create info internally.
the docs on quite unclear, have found in testing if don't release cgimagerefs , cgdataproviderrefs cause application memory warnings... , crash.
not sure why have crash, in doing quick test with:
uiimageview *view = [[uiimageview alloc] init]; int = 128; unsigned char *topologyimage = malloc(i*i*4*sizeof(unsigned char)); for(int i=0; i<i*i*4; i++) { topologyimage[i] = 100; } for(int i=0; i<1000; i++) { cgcolorspaceref colorspaceref=cgcolorspacecreatedevicergb(); cgbitmapinfo bitmapinfo = kcgbitmapbyteorderdefault | kcgimagealphalast; cgcolorrenderingintent renderingintent=kcgrenderingintentdefault; cgdataproviderref provider=cgdataprovidercreatewithdata(null,topologyimage,(i*i*4),null); cgimageref imageref=cgimagecreate(i,i,8,4*8,4*i,colorspaceref,bitmapinfo,provider,null,false,renderingintent); cgcolorspacerelease(colorspaceref); cgdataproviderrelease(provider); uiimage *img=[uiimage imagewithcgimage:imageref]; view.image = img; cgimagerelease(imageref); } free(topologyimage); seems work fine me, whatever causing crash seems because of outside of example, illustration how got image info topologyimage
caching crash uiimageview uiimage
Comments
Post a Comment