473,396 Members | 1,725 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

last function to be called

Hi,

I want a particular function to run after everything has beeen
destructed.
It's looking for memory leaks.

atexit() doesn't seem to suit my purpose as global statics can be
destructed
after all the atexit()s.

Would a global static at the beginning of the file containing main()
do the job
or have I run into another aspect of the "static initialization order
fiasco"?
--
Nick Keighley

My god it's full of stars!
Dave Bowman, on seeing HAL's source code

Feb 5 '07 #1
3 1294
"Nick Keighley" <ni******************@hotmail.comwrote in
news:11**********************@m58g2000cwm.googlegr oups.com:
Hi,

I want a particular function to run after everything has beeen
destructed.
It's looking for memory leaks.

atexit() doesn't seem to suit my purpose as global statics can be
destructed
after all the atexit()s.

Would a global static at the beginning of the file containing main()
do the job
or have I run into another aspect of the "static initialization order
fiasco"?
Compiler-dependant. A global static at the beginning of the translation
unit containing main() will only be known to have been constructed before
main, but not necessarily before global objects in other translation units.
Feb 5 '07 #2
On 5 Feb, 16:16, Andre Kostur <nntps...@kostur.netwrote:
"Nick Keighley" <nick_keighley_nos...@hotmail.comwrote innews:11**********************@m58g2000cwm.google groups.com:
Hi,
I want a particular function to run after everything has beeen
destructed.
It's looking for memory leaks.
atexit() doesn't seem to suit my purpose as global statics can be
destructed
after all the atexit()s.
Would a global static at the beginning of the file containing main()
do the job
or have I run into another aspect of the "static initialization order
fiasco"?

Compiler-dependant. A global static at the beginning of the translation
unit containing main() will only be known to have been constructed before
main, but not necessarily before global objects in other translation units.

so the question is not, portably, answerable? There is no easy way to
generate
a last function or DTOR?
--
Nick Keighley

Feb 6 '07 #3
Nick Keighley wrote:
On 5 Feb, 16:16, Andre Kostur <nntps...@kostur.netwrote:
>"Nick Keighley" <nick_keighley_nos...@hotmail.comwrote innews:11**********************@m58g2000cwm.google groups.com:
>>Hi,
I want a particular function to run after everything has beeen
destructed.
It's looking for memory leaks.
atexit() doesn't seem to suit my purpose as global statics can be
destructed
after all the atexit()s.
Would a global static at the beginning of the file containing main()
do the job
or have I run into another aspect of the "static initialization order
fiasco"?
Compiler-dependant. A global static at the beginning of the translation
unit containing main() will only be known to have been constructed before
main, but not necessarily before global objects in other translation units.


so the question is not, portably, answerable? There is no easy way to
generate
a last function or DTOR?
--
Nick Keighley
Perhaps too intrusive/fragile for your needs, but you could modify every
translation unit to have a global variable of some type T as the first
thing in that translation unit. T could have a static reference
counter, and when ~T() is executed with reference count 1, that should
be the last thing to execute.

--
Alan Johnson
Feb 6 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: jason | last post by:
I've got this javascript routine (i found on google - thank you) in an asp.net page that on page reload sets the cursor of a textbox to the last line. It works great! Using a similar concept, I...
13
by: SimonC | last post by:
I would like to return data from the last 2 weeks of each given month in Javascript, but in 2 formats. So, the penultimate week (Monday to Sunday) and the last week (Monday to ??) I'm not...
1
by: Scott | last post by:
My little access app is now working happily with a "browse" button that lets me link to a .mdb data-set for the app to work with. Problem is, that I store various data sets on different machines...
3
by: Ryan Liu | last post by:
Hi there, I got a NullReferenceException when delete last row in a datagrid. I had hard time to solve since it does not occur in my own code. I put a datagrid in my inherited user control,...
5
by: JonH | last post by:
Ok, I have this dynamically created table in my one of my php forms that shows the names of the people the user has entered into a text field. When they hit add a row displays, showing the name...
5
by: Denis Petronenko | last post by:
Hello, for(int i=0; i<100; ++i){ cout << i << ","; } // how can i remove last comma here? ...... cout << endl;
16
by: mailforpr | last post by:
How do I do that? The thing is, the only information I have about the iterator is the iterator itself. No container it is belonging to or anything. Like template<Iteratorvoid...
2
by: Kevin Burton | last post by:
I don't think I understand the last() function. I have a document that looks like: <Root> <Header>Some text</Header> <Message> <MessageID>1</MessageID> . . . . </Message>
0
by: marlberg | last post by:
Platform: Windows2000, WindowsXP, Windows Vista, etc Language: C#, ASP.NET Pre-compiled Libraries: Enterprise Library 3.0 full I have a requirement to implement in and display in C# and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.