Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
article
Free access

Borrow, copy or steal?: loans and larceny in the orthodox canonical form

Published: 01 October 1998 Publication History

Abstract

Dynamic memory management in C++ is complex, especially across the boundaries of library abstract data types. C++ libraries designed in the orthodox canonical form (OCF) alleviate some of the problems by ensuring that classes which manage any kind of heap structures faithfully copy and delete these. However, in certain common circumstances, OCF heap structures are wastefully copied multiple times. General reference counting is not an option in OCF, since a shared body violates the intended value semantics; although a copy-on-write policy can be made to work with borrowed heap structures. A simpler ownership policy, based on larceny, allows low-level memory manager objects to steal heap structures from temporary variables, in properly isolated circumstances. Various strategies for regulating theft are presented, ranging from pilfer-constructors to locks on heap data. Larceny has similarities with other transfer of ownership patterns, but is more a core implementation technique designed to improve the efficiency and effectiveness of OCF-conformant libraries.

References

[1]
P S Almeida, "Balloon types: controlling sharing of state in data types", Proc. l lth European Conf. Object-Oriented Prog. (1997), Springer Verlag, 32-59.
[2]
G Booch, "Frameworks", chapter 9 in: Object- Oriented Analysis and Design with Applications, 2nd edn. (1994), Benjamin- Cummings.
[3]
M Brain and L Lovette, Developing Professional Applications for Windows '95 and NT using MFC (1997), Prentice Hall.
[4]
D Coleman, P Arnold, S Bodoff, C Dollin, H Gilchrist, F Heyes and P Jeremaes, Object- Oriented Development: The Fusion Method (1994), Prentice Hall.
[5]
T Cargill, "Localised ownership: managing dynamic objects", in {VCK961 (1996), part 1, chapter I.
[6]
G Colvin, "Why is auto_ptr defined the way it is?", The comp.std.c++ FAQ, question C2, http.'//real ity. s g i. com/auste rn_mti/std-c + + /faq.html, 13 May (1998).
[7]
J Coplien, Advanced C++ Programming Styles and Idioms (1992), Addison-Wesley.
[8]
E Gamma, R Helm, R Johnson and J Vlissides, Design Patterns: Elements of Reusable Object-Oriented Software (1995), Addison Wesley.
[9]
K Gorlen, S Orlow and P Plexico, Data Abstraction and Object-Oriented Programming in C+ + (1990), John Wiley.
[10]
J Hogg, D Lea, R Holt, A Wills and D de Champeaux, "The Geneva Convention on the treatment of object aliasing", OOPS Messenger, April (1992).
[11]
J Hogg, "Islands: aliasing protection in object-oriented languages", Proc. 6th A CM Conf. Object-Oriented Prog., Sys., Lang. and Appl., SigPlan Notices 26(10) (1991).
[12]
C S Horstmann, Mastering Object-Oriented Design in C+ + (1995), Wiley.
[13]
D Lea, "The GNU C++ Library", C++ Report, June (1993); reprinted in {Lipp96}; revised as: http://gee.cs.oswego.edu/dl/libg+ +paper/ libg++/libg++.html, (1995).
[14]
D Lea, Concurrent Programming in Java - Design Principles and Patterns (1996), Addison Wesley.
[15]
S Lippman (ed), C++ Gems (1996), SIGS Books.
[16]
S Meyers, Effective C+ +: 50 Specific Ways to improve Your Programs and Designs (1992), Addison-Wesley.
[17]
N Minsky, "Towards alias-free pointers", Proc. l Oth European Conf. Object-Oriented Prog. (1996), Springer Verlag, 189-209
[18]
Rational, C++ Booch Components Class Catalog, version 2.3 (1993), Rational.
[19]
Rogue Wave, Tools.h++ Foundation Class Library for C++ Programming, version 6 (1995), Rogue Wave Software, Inc.
[20]
A Sane and R Campbell, "Resource exchanger: a behavioural pattern for lowoverhead concurrent resource management", in {VCK96} (1996), part 7, chapter 8.
[21]
R Strom, D Bacon, A Goldberg, A Lowry, D Yellin and S Yemini, Hermes: a Language for Distributed Computing (1991), Prentice Hall.
[22]
G L Steele, The Common Lisp Reference Manual (1986), Digital Press.
[23]
A Stepanov and M Lee, "The standard template library", Technical Report, Hewlett- Packard Laboratories, May (1994).
[24]
B Stroustrup, The C++ Programming Language, 2nd edn, Addison-Wesley.
[25]
J Vlissides, J Coplien and N Kerth (eds.), Pattern Languages of Program Design, 2 (1996), Addison-Wesley.
[26]
F Wild, "Instantiating code patterns", Dr Dobb's Journal, June (1996), 72.

Cited By

View all
  • (2012)Summary-based data-flow analysis that understands regular composite objects and iteratorsACM SIGAPP Applied Computing Review10.1145/2432546.243254912:4(36-47)Online publication date: 1-Dec-2012
  • (2012)Exploiting regularity of user-defined types to improve precision of program analysesProceedings of the 27th Annual ACM Symposium on Applied Computing10.1145/2245276.2232059(1743-1750)Online publication date: 26-Mar-2012
  • (2022)An empirical study of the Python/C API on evolution and bug patternsJournal of Software: Evolution and Process10.1002/smr.250735:2Online publication date: 6-Sep-2022
  • Show More Cited By

Recommendations

Comments

Information & Contributors

Information

Published In

Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 01 October 1998
Published in SIGPLAN Volume 33, Issue 10

Check for updates

Author Tags

  1. C++
  2. borrowing
  3. copy-on-write
  4. implementation strategies
  5. larceny
  6. memory management
  7. stealing
  8. transfer of ownership

Qualifiers

  • Article

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)103
  • Downloads (Last 6 weeks)24
Reflects downloads up to 21 Sep 2024

Other Metrics

Citations

Cited By

View all
  • (2012)Summary-based data-flow analysis that understands regular composite objects and iteratorsACM SIGAPP Applied Computing Review10.1145/2432546.243254912:4(36-47)Online publication date: 1-Dec-2012
  • (2012)Exploiting regularity of user-defined types to improve precision of program analysesProceedings of the 27th Annual ACM Symposium on Applied Computing10.1145/2245276.2232059(1743-1750)Online publication date: 26-Mar-2012
  • (2022)An empirical study of the Python/C API on evolution and bug patternsJournal of Software: Evolution and Process10.1002/smr.250735:2Online publication date: 6-Sep-2022
  • (2021)Static Type Inference for Foreign Functions of Python2021 IEEE 32nd International Symposium on Software Reliability Engineering (ISSRE)10.1109/ISSRE52982.2021.00051(423-433)Online publication date: Oct-2021
  • (2020)The Python/C API: Evolution, Usage Statistics, and Bug Patterns2020 IEEE 27th International Conference on Software Analysis, Evolution and Reengineering (SANER)10.1109/SANER48275.2020.9054835(532-536)Online publication date: Feb-2020
  • (2007)Raw pointers in application classes of C++ considered harmfulACM SIGPLAN Notices10.1145/1288258.128826242:4(23-31)Online publication date: 1-Apr-2007

View Options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Get Access

Login options

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media