Click here to Skip to main content
15,887,135 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Cannot print exception string because Exception.ToString() failed. Pin
jschell18-Dec-23 5:25
jschell18-Dec-23 5:25 
GeneralRe: Cannot print exception string because Exception.ToString() failed. Pin
Steve Raw15-Dec-23 4:25
professionalSteve Raw15-Dec-23 4:25 
GeneralRe: Cannot print exception string because Exception.ToString() failed. Pin
Marc Clifton15-Dec-23 5:07
mvaMarc Clifton15-Dec-23 5:07 
GeneralRe: Cannot print exception string because Exception.ToString() failed. Pin
raddevus15-Dec-23 4:30
mvaraddevus15-Dec-23 4:30 
GeneralRe: Cannot print exception string because Exception.ToString() failed. Pin
Marc Clifton15-Dec-23 5:07
mvaMarc Clifton15-Dec-23 5:07 
GeneralRe: Cannot print exception string because Exception.ToString() failed. Pin
CPallini15-Dec-23 4:45
mveCPallini15-Dec-23 4:45 
GeneralRe: Cannot print exception string because Exception.ToString() failed. Pin
BernardIE531715-Dec-23 5:20
BernardIE531715-Dec-23 5:20 
GeneralRe: Cannot print exception string because Exception.ToString() failed. Pin
jschell15-Dec-23 5:27
jschell15-Dec-23 5:27 
The general problem is that one can get an out of memory problem even when there is seemingly plenty of memory for the application.

I believe this can happen in Java. [Edit] (See other post - it can happen on Java.)
I know it can happen in .Net.

For .Net it happens when the Large Object Heap runs out of memory. I think there can be other cases as well.

Now why would that matter for the code given? Because the string it attempts to build would result in an object that would go on the Large Object Heap.

In my experience I saw this when the application was doing a lot of transfers of files by using in memory copies of the files between different layers. Due to over generalization of course. Insisting on passing streams between layers and then each layer copied the stream into memory and it went down the chain. Then when one adds threads to that it starts chewing up memory.

In terms of the Exception class (or children) I have seen layers that caught an exception, then used that exception stack trace to create the message for the Exception that it threw. Which might be useful and even required if going over the wire it will lead to very large Exception messages.

The Large Object Heap cutoff is the rather odd number of 85,000.

[Edit] - Java example post
The Lounge[^]

modified 18-Dec-23 12:47pm.

GeneralRe: Cannot print exception string because Exception.ToString() failed. Pin
RickZeeland15-Dec-23 5:30
mveRickZeeland15-Dec-23 5:30 
NewsFahrenheit Pin
Jeremy Falcon15-Dec-23 4:06
professionalJeremy Falcon15-Dec-23 4:06 
GeneralRe: Fahrenheit Pin
den2k8815-Dec-23 4:11
professionalden2k8815-Dec-23 4:11 
GeneralRe: Fahrenheit Pin
Jeremy Falcon15-Dec-23 4:13
professionalJeremy Falcon15-Dec-23 4:13 
GeneralRe: Fahrenheit Pin
den2k8815-Dec-23 4:18
professionalden2k8815-Dec-23 4:18 
GeneralRe: Fahrenheit Pin
CPallini15-Dec-23 4:37
mveCPallini15-Dec-23 4:37 
GeneralRe: Fahrenheit Pin
Jeremy Falcon15-Dec-23 7:20
professionalJeremy Falcon15-Dec-23 7:20 
GeneralRe: Fahrenheit Pin
trønderen16-Dec-23 6:20
trønderen16-Dec-23 6:20 
GeneralRe: Fahrenheit Pin
Jeremy Falcon17-Dec-23 2:51
professionalJeremy Falcon17-Dec-23 2:51 
GeneralRe: Fahrenheit Pin
trønderen17-Dec-23 7:17
trønderen17-Dec-23 7:17 
GeneralRe: Fahrenheit Pin
jschell18-Dec-23 6:48
jschell18-Dec-23 6:48 
GeneralRe: Fahrenheit Pin
Jeremy Falcon15-Dec-23 4:16
professionalJeremy Falcon15-Dec-23 4:16 
GeneralRe: Fahrenheit Pin
trønderen16-Dec-23 6:28
trønderen16-Dec-23 6:28 
GeneralRe: Fahrenheit Pin
Jeremy Falcon17-Dec-23 2:51
professionalJeremy Falcon17-Dec-23 2:51 
GeneralRe: Fahrenheit Pin
GKP199215-Dec-23 4:19
professionalGKP199215-Dec-23 4:19 
GeneralRe: Fahrenheit Pin
Jeremy Falcon15-Dec-23 7:20
professionalJeremy Falcon15-Dec-23 7:20 
GeneralRe: Fahrenheit Pin
Richard MacCutchan15-Dec-23 4:25
mveRichard MacCutchan15-Dec-23 4:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.