Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.

Posts: 22
Registered: ‎03-05-2011
My Device: Not Specified

Memory Problems with Custom Control Image View

I created a Custom Control from C ("RemoteImageView") basically what it does is present a default image when it deploys and waits for another to be downloaded and replaces the default. I use it in several places in the app but i particularly had problems in the galleries, because the app locks, it occurs to me that maybe this is not releasing memory properly.
I enclose classes of the RemoteImageView and the Gallery.

I'm pushing the gallery through a navigationPane from which the next  signal is connected:
void App :: popFinished (bb :: cascades :: Page * page)
     delete page;
I was hoping by delete the page it will delete all its children (including RemoteImageViews) but apparently it is not doing it, maybe that's not how you delete them or maybe I'm not setting the correct kinship.

I hope you can help me, maybe it's something basic, please remember to be patient as I walked entirely in Java and did not have these problems ...


 * RemoteImageView.cpp
 *  Created on: Oct 2, 2012
 *      Author: aluialarid

#include "RemoteImageView.h"
#include <bb/cascades/Container>
#include <bb/cascades/ImageView>
#include <bb/cascades/ScalingMethod>
#include <bb/cascades/DockLayout>

using namespace bb::cascades;

RemoteImageView::RemoteImageView(Container *parent) :
        CustomControl(parent) {
	mRootContainer = new Container();
	mRootContainer->setLayout(new DockLayout);
	imageView = ImageView::create().image(
	connect(this, SIGNAL(urlChanged(QString)), this, SLOT(onurlChanged()));
	//  connect(mRootContainer->layout(), SIGNAL(CreationCompleted()), this, SLOT(onurlChanged()));


RemoteImageView::~RemoteImageView() {
	//delete mRootContainer;

void RemoteImageView::loadImage() {
	qDebug() << murl;
	QNetworkRequest request = QNetworkRequest();
	QNetworkAccessManager* nam = new QNetworkAccessManager(this);
	bool result = connect(nam, SIGNAL(finished(QNetworkReply*)), this,

void RemoteImageView::onurlChanged() {

void RemoteImageView::onImageLoaded(QNetworkReply* reply) {
	if (reply->error() != QNetworkReply::NoError) {
		emit imageUnavailable();
	Image image = Image(reply->readAll());

void RemoteImageView::seturl(QString url) {
	if (murl.compare(url) != 0) {
		murl = url;
		emit urlChanged(murl);
QString RemoteImageView::URL() {
	return murl;


 * RemoteImageView.h
 *  Created on: Oct 2, 2012
 *      Author: aluialarid


#include <bb/cascades/CustomControl>
#include <bb/cascades/Container>
#include <bb/cascades/ImageView>
#include <bb/cascades/Container>
#include <QTNetwork>

namespace bb {
	namespace cascades {
		class Container;
using namespace bb::cascades;

class RemoteImageView: public CustomControl {
	Q_PROPERTY(QString url READ URL WRITE seturl NOTIFY urlChanged)

	RemoteImageView(Container *parent=0);
	virtual ~RemoteImageView();
	Container* mRootContainer;
	ImageView* imageView;
    Q_INVOKABLE void loadImage();
    void seturl(QString url);
    QString URL();

public	slots:
	void onImageLoaded(QNetworkReply* reply);
	void onurlChanged();
			void imageUnavailable();
			void urlChanged(QString url);

	QString murl;




/* *
 *  Created on: Oct 2, 2012
 *      Author: aluialarid
import bb.cascades 1.0
import custom.lib 1.0

Page {
    id: galleryPage
    Container {
        background: Color.create("#000000")
        verticalAlignment: VerticalAlignment.Fill
        HeaderField {
            layoutProperties: StackLayoutProperties {
                spaceQuota: 1
        ListView {
            layoutProperties: StackLayoutProperties {
                spaceQuota: 7
            objectName: "galleryView"
            function itemType(data, indexPath) {
                return "item";
            layout: GridListLayout {
                cellAspectRatio: 1.4
            listItemComponents: [
                ListItemComponent {
                    type: "item"
                    RemoteImageView {
                        url: ListItemData.imgURL
            onTriggered: {
                var affectedItem = dataModel.data(indexPath);
                cs.pushImagePage(affectedItem.title, affectedItem.imgURL);

This is how i push the gallery: 


void App::pushGallery(QString key) {
	QMap<QString, GroupDataModel*>::iterator it = m_imageMap.find(key);
	if (it != m_imageMap.end()) {
		GroupDataModel* gdm = it.value();

		QmlDocument *pageQml =
		pageQml->setContextProperty("cs", this);

		Page *appPage = pageQml->createRootObject<Page>();

		ListView* galleryView = appPage->findChild<ListView *>("galleryView");


New Contributor
Posts: 8
Registered: ‎01-13-2011
My Device: Not Specified

Re: Memory Problems with Custom Control Image View

[ Edited ]

did you ever figure this out? I wrote a very similar class and tried a bunch of different things to get the memory to release properly or something.  I am using it in a list view and all the images load correctly but when I scroll they get filled in with prevous images in memory. duplicating and triplicating. its like custom controls are not released properly via the parent.