CFP last date
20 December 2024
Reseach Article

Memory Management via Ownership Concept Rust and Swift: Experimental Study

by Elaf Alhazmi, Abdulwahab Aljubairy, Ahoud Alhazmi
International Journal of Computer Applications
Foundation of Computer Science (FCS), NY, USA
Volume 183 - Number 22
Year of Publication: 2021
Authors: Elaf Alhazmi, Abdulwahab Aljubairy, Ahoud Alhazmi
10.5120/ijca2021921572

Elaf Alhazmi, Abdulwahab Aljubairy, Ahoud Alhazmi . Memory Management via Ownership Concept Rust and Swift: Experimental Study. International Journal of Computer Applications. 183, 22 ( Aug 2021), 1-10. DOI=10.5120/ijca2021921572

@article{ 10.5120/ijca2021921572,
author = { Elaf Alhazmi, Abdulwahab Aljubairy, Ahoud Alhazmi },
title = { Memory Management via Ownership Concept Rust and Swift: Experimental Study },
journal = { International Journal of Computer Applications },
issue_date = { Aug 2021 },
volume = { 183 },
number = { 22 },
month = { Aug },
year = { 2021 },
issn = { 0975-8887 },
pages = { 1-10 },
numpages = {9},
url = { https://ijcaonline.org/archives/volume183/number22/32054-2021921572/ },
doi = { 10.5120/ijca2021921572 },
publisher = {Foundation of Computer Science (FCS), NY, USA},
address = {New York, USA}
}
%0 Journal Article
%1 2024-02-07T01:17:30.361421+05:30
%A Elaf Alhazmi
%A Abdulwahab Aljubairy
%A Ahoud Alhazmi
%T Memory Management via Ownership Concept Rust and Swift: Experimental Study
%J International Journal of Computer Applications
%@ 0975-8887
%V 183
%N 22
%P 1-10
%D 2021
%I Foundation of Computer Science (FCS), NY, USA
Abstract

One of the most important features to help facilitate reliable design in a programming language is memory management design. There are two wide-spread approaches: manual and automatic memory management, known as garbage collection (GC). Recently, a third approach which is ownership design has been fully adapted in new modern programming languages such as Rust and Swift. Rust uses ownership to eliminate high degree memory problems such as memory leak, dangling pointer, and use after free. Rust follows deterministic syntax-driven memory management depending on static ownership rules implemented and enforced by the rustc compiler. Swift also implements ownership concept in automatic reference counting (ARC). Though the ownership concept is adapted in Swift, it is not a memory-safe language because of the possibility of strong reference cycles. In this paper, we will illustrate the fundamental of ownership and the consequences of memory safety guarantees and issues related to Rust and Swift.We also conducted an experiment to compare the elapsed time binary tree allocation and deallocation in five programming languages C, C++, Java, Swift and Rust.

References
  1. Sultan S Al-Qahtani, Pawel Pietrzynski, Luis F Guzman, Rafik Arif, and Adrien Tevoedjre. Comparing selected criteria of programming languages java, php, c++, perl, haskell, aspectj, ruby, cobol, bash scripts and scheme revision 1.0-a team cplgroup comp6411-s10 term report. arXiv preprint arXiv:1008.3434, 2010.
  2. Alexandra Back and Emma Westman. Comparing programming languages in google code jam. Master’s thesis, 2017.
  3. Abhiram Balasubramanian, Marek S Baranowski, Anton Burtsev, Aurojit Panda, Zvonimir Rakamari´c, and Leonid Ryzhyk. System programming in rust: Beyond safety. In Proceedings of the 16th Workshop on Hot Topics in Operating Systems, pages 156–161, 2017.
  4. Ivo Balbaert. Rust Essentials: A quick guide to writing fast, safe, and concurrent systems and applications. Packt Publishing Ltd, 2017.
  5. Stephen M Blackburn, Perry Cheng, and Kathryn S McKinley. Oil and water? high performance garbage collection in java with mmtk. In Proceedings. 26th International Conference on Software Engineering, pages 137–146. IEEE, 2004.
  6. Hans-J Boehm. Threads cannot be implemented as a library. ACM Sigplan Notices, 40(6):261–268, 2005.
  7. Chandrasekhar Boyapati, Alexandru Salcianu, William Beebee Jr, and Martin Rinard. Ownership types for safe region-based memory management in real-time java. In Proceedings of the ACM SIGPLAN 2003 conference on Programming language design and implementation, pages 324–337, 2003.
  8. Marco Couto, Rui Pereira, Francisco Ribeiro, Rui Rua, and João Saraiva. Towards a green ranking for programming languages. In Proceedings of the 21st Brazilian Symposium on Programming Languages, pages 1–8, 2017.
  9. The Rust Project Developers. Reference cycles can leak memory. https://doc.rust-lang.org/book/secon d-edition/ch15-06-reference-cycles.html, 2011 (accessed April 2018).
  10. The Rust Project Developers. Ownership, 2018.
  11. James Goodwill, Wesley Matlock, and Bruce Wade. Beginning Swift games development for iOS. Springer, 2015.
  12. Apple Inc. Advanced memory management programming guide. https://developer.apple.com/library/ar chive/documentation/Cocoa/Conceptual/MemoryMgm t/Articles/MemoryMgmt.html#//apple_ref/doc/uid /10000011i, 2012 (accessed March 2018).
  13. Apple Inc. Transitioning to arc release notes. https://deve loper.apple.com/library/archive/releasenotes/O bjectiveC/RN-TransitioningToARC/Introduction/I ntroduction.html#//apple_ref/doc/uid/TP4001122 6, 2012 (accessed March 2018).
  14. Apple Inc. Automatic reference counting. https://docs.s wift.org/swift-book/LanguageGuide/AutomaticRef erenceCounting.html, 2018 (accessed March 2018).
  15. Apple Inc. Collection types, 2018 (accessed March 2018).
  16. Apple Inc. Deinitialization. https://docs.swift.org/s wift-book/LanguageGuide/Deinitialization.html , 2018 (accessed March 2018).
  17. Apple Inc. Initialization. https://docs.swift.org/swi ft-book/LanguageGuide/Initialization.html, 2018 (accessed March 2018).
  18. Ralf Jung, Jacques-Henri Jourdan, Robbert Krebbers, and Derek Dreyer. Rustbelt: Securing the foundations of the rust programming language. Proceedings of the ACM on Programming Languages, 2(POPL):1–34, 2017.
  19. Steve Klabnik and Carol Nichols. The Rust Programming Language (Covers Rust 2018). No Starch Press, 2019.
  20. Yi Lin, Stephen M Blackburn, Antony L Hosking, and Michael Norrish. Rust as a language for high performance gc implementation. ACM SIGPLAN Notices, 51(11):89–98, 2016.
  21. Waqar Malik. Learn Swift 2 on the Mac: For OS X and IOS. Springer, 2015.
  22. Nicholas D Matsakis and Felix S Klock. The rust language. ACM SIGAda Ada Letters, 34(3):103–104, 2014.
  23. Julio CB Mattos and Luigi Carro. Object and method exploration for embedded systems applications. In Proceedings of the 20th annual conference on Integrated circuits and systems design, pages 318–323, 2007.
  24. Sebastian Nanz and Carlo A Furia. A comparative study of programming languages in rosetta code. In 2015 IEEE/ACM 37th IEEE International Conference on Software Engineering, volume 1, pages 778–788. IEEE, 2015.
  25. Lutz Prechelt. An empirical comparison of seven programming languages. Computer, 33(10):23–29, 2000.
  26. Baishakhi Ray, Daryl Posnett, Vladimir Filkov, and Premkumar Devanbu. A large scale study of programming languages and code quality in github. In Proceedings of the 22nd ACM SIGSOFT International Symposium on Foundations of Software Engineering, pages 155–165, 2014.
  27. Rufflewind. Graphical depiction of ownership and borrowing in rust. https://rufflewind.com/2017-02-15/rust-m ove-copy-borrow, 2017 (accessed June 2018).
  28. Narendran Sachindran and J Eliot B Moss. Mark-copy: Fast copying gc with less space overhead. In Proceedings of the 18th annual ACM SIGPLAN conference on Object-oriented programing, systems, languages, and applications, pages 326–343, 2003.
  29. Sudhir Sangappa, K Palaniappan, and Richard Tollerton. Benchmarking java against c/c++ for interactive scientific visualization. In Proceedings of the 2002 joint ACM-ISCOPE conference on Java Grande, pages 236–236, 2002.
  30. Harwinder Singh. Speed performance between swift and objective-c. 2016.
  31. Jonathan Turner. Rust 2017 survey results. https://blog.r ust-lang.org/2017/09/05/Rust-2017-Survey-Resul ts.html, Sep 2017.
Index Terms

Computer Science
Information Sciences

Keywords

Ownership Manual Memory Management Garbage Collection