Stack size increases dramatically when I DELETE pictures
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Stack size increases dramatically when I DELETE pictures
Hi,
I noticed that I had accidentally created a card with all the graphics that I use for buttons, etc. and that I duplicated and filled in this card for every record I have (1000s of records).
I thought that if I created a substack with one card with the images and then have the buttons point to the new IDs in the Image Library that it would save space. That way, each image for each button is not being duplicated for each record I have (maybe it isn't anyhow ... these images were part of a background).
When I removed the images, the stack size increased in size from 9 MB to almost 25 MB!!! I'm trying to understand why.
Larry
I noticed that I had accidentally created a card with all the graphics that I use for buttons, etc. and that I duplicated and filled in this card for every record I have (1000s of records).
I thought that if I created a substack with one card with the images and then have the buttons point to the new IDs in the Image Library that it would save space. That way, each image for each button is not being duplicated for each record I have (maybe it isn't anyhow ... these images were part of a background).
When I removed the images, the stack size increased in size from 9 MB to almost 25 MB!!! I'm trying to understand why.
Larry
Hi Larry,
Are you sure that you are comparing stack sizes at the right moments? Have you saved the stack right before and immediately after deleting the pictures?
You could have a look in the application browser to see which objects are there. Perhaps there are some unexpected objects laying around?
A stack with literally thousands of cards and on each card a few buttons and fields as well as text in the fields can easily take several megabytes. I am not very surprised by the size of your stack.
Actually, I think you are following the wrong approach. By keeping all records on cards, your stack will become relatively big and extremely slow. Soon, the find command will take several minutes to complete. I did this with a stack with 36000 records and on a 350Mhz machine, I needed about 20 minutes to find a record (several years ago).
You will get a much smaller and faster stack if you keep all your data in a file or in custom properties. Search for the data you need with offset functions or repeat loops, for example. Another very fast method is the use of a real database, such as SQLite or mySQL.
Good luck,
Mark
Are you sure that you are comparing stack sizes at the right moments? Have you saved the stack right before and immediately after deleting the pictures?
You could have a look in the application browser to see which objects are there. Perhaps there are some unexpected objects laying around?
A stack with literally thousands of cards and on each card a few buttons and fields as well as text in the fields can easily take several megabytes. I am not very surprised by the size of your stack.
Actually, I think you are following the wrong approach. By keeping all records on cards, your stack will become relatively big and extremely slow. Soon, the find command will take several minutes to complete. I did this with a stack with 36000 records and on a 350Mhz machine, I needed about 20 minutes to find a record (several years ago).
You will get a much smaller and faster stack if you keep all your data in a file or in custom properties. Search for the data you need with offset functions or repeat loops, for example. Another very fast method is the use of a real database, such as SQLite or mySQL.
Good luck,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Hi Mark,
Yes, my goal this week is to convert it over to SQLite.
Thankfully I kept backups of my project. I have the project at <10MB and then after I run the following script. Once that is saved it rests at close to 23MB.
on mouseUp
--Clean up other cards in main stack to get rid of copied pictures that we really don't need lying around.
lock screen
put fld fDeleteThese into vDeletionList
put the number of cards in stack "TSI.rev" into vTotalCards
repeat with tCardRun = 1 to vTotalCards
go to card tCardRun of stack "TSI.rev"
put number of lines of vDeletionList into vDeletionListNumLines
repeat with tImageRun = 1 to vDeletionListNumLines
put line tImageRun of vDeletionList into vImageName
if exists (image vImageName of card tCardRun of stack "TSI.rev") then
delete image vImageName of card tCardRun of stack "TSI.rev"
end if
end repeat
end repeat
unlock screen
end mouseUp
Yes, my goal this week is to convert it over to SQLite.
Thankfully I kept backups of my project. I have the project at <10MB and then after I run the following script. Once that is saved it rests at close to 23MB.
on mouseUp
--Clean up other cards in main stack to get rid of copied pictures that we really don't need lying around.
lock screen
put fld fDeleteThese into vDeletionList
put the number of cards in stack "TSI.rev" into vTotalCards
repeat with tCardRun = 1 to vTotalCards
go to card tCardRun of stack "TSI.rev"
put number of lines of vDeletionList into vDeletionListNumLines
repeat with tImageRun = 1 to vDeletionListNumLines
put line tImageRun of vDeletionList into vImageName
if exists (image vImageName of card tCardRun of stack "TSI.rev") then
delete image vImageName of card tCardRun of stack "TSI.rev"
end if
end repeat
end repeat
unlock screen
end mouseUp
Hi Larry,
I'm playing with your script, but need to know what fDeleteThese is. Is that a variable or a field name? Why do you refer to your stack as "TSI.rev" and not simply "TSI"?
Best,
Mark
I'm playing with your script, but need to know what fDeleteThese is. Is that a variable or a field name? Why do you refer to your stack as "TSI.rev" and not simply "TSI"?
Best,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Hi Larry,
The different isn't really that big, but you might try the following script. Before you do anything else, after running the script, check the size of the stack. Is it still larger than you expect?
Do you already have the pictures copied to a substack, before you delete the pictures?
Best,
Mark
The different isn't really that big, but you might try the following script. Before you do anything else, after running the script, check the size of the stack. Is it still larger than you expect?
Code: Select all
on mouseUp
--Clean up other cards in main stack to get rid of copied pictures that we
-- really don't need lying around.
lock screen
lock messages
put fld "fDeleteThese" into vDeletionList
go stack "TSI.rev" in new window
repeat with tCardRun = 1 to number of cards of this stack
repeat for each line myImg in vDeletionList
if there is an img myImg of cd tCardRun then delete img myImg of cd tCardRun
end repeat
end repeat
unlock screen
unlock messages
-- compress and save, same as Save in File menu
compress this stack
save this stack
end mouseUp
Best,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
I don't get it ... your script works (apart from the compress this stack line). And the resulting file is somewhat smaller. Hmmmm. So you need to go to the stack and then iterate through ... that makes sense to me.
Well Mark ... once again you have led me into the deeper mysteries of RunRev.
Thanks!
Larry
Well Mark ... once again you have led me into the deeper mysteries of RunRev.
Thanks!
Larry
Hi Larry,
Do you already have the pictures copied to a substack, before you delete the pictures?
How much smaller is the stack exactly, after running the script?
Best,
Mark
Do you already have the pictures copied to a substack, before you delete the pictures?
How much smaller is the stack exactly, after running the script?
Best,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode